Fixed progressbar for reindex

Signed-off-by: Janos SUTO <sj@acts.hu>
This commit is contained in:
Janos SUTO 2021-07-02 10:25:19 +02:00
parent 817df3c172
commit 9360b429ce

View File

@ -75,12 +75,10 @@ uint64 get_max_meta_id(struct session_data *sdata){
uint64 retrieve_email_by_metadata_id(struct session_data *sdata, struct data *data, uint64 from_id, uint64 to_id, struct config *cfg){
char s[SMALLBUFSIZE];
uint64 stored_id=0, reindexed=0, delta;
uint64 stored_id=0, reindexed=0;
struct parser_state state;
struct sql sql;
delta = to_id - from_id;
if(cfg->enable_folders == 1)
snprintf(s, sizeof(s)-1, "SELECT m.`id`, `piler_id`, `arrived`, `sent`, f.folder_id FROM %s m, %s f WHERE m.id=f.id AND (m.id BETWEEN %llu AND %llu) AND `deleted`=0", SQL_METADATA_TABLE, SQL_FOLDER_MESSAGE_TABLE, from_id, to_id);
else
@ -137,6 +135,9 @@ uint64 retrieve_email_by_metadata_id(struct session_data *sdata, struct data *da
unlink(filename);
if(progressbar){
uint64 delta = to_id - from_id;
if(delta == 0) delta = 1;
printf("processed: %8llu [%3d%%]\r", reindexed, (int)(100*reindexed/delta));
fflush(stdout);
}