From: Marco Bettini Date: Mon, 6 Mar 2023 15:34:37 +0000 (+0000) Subject: indexer: index_mailbox_precache() - Ensure updates are sent even with few messages... X-Git-Tag: 2.4.0~2734 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=35a90e7fa9767bf2f9bbad16a4ae0bd324b6b3d2;p=thirdparty%2Fdovecot%2Fcore.git indexer: index_mailbox_precache() - Ensure updates are sent even with few messages and very slow processing With the former behavior, if we have 101 messages and they take 30 seconds, the client sees the progress stuck at 0% for most the processign time, only to see it jump to 99% a fraction of a second before the competion. This change ensures that the client sees a timely update every time the integer percentage actually changes. --- diff --git a/src/indexer/master-connection.c b/src/indexer/master-connection.c index 8a6e1f905b..636e26d345 100644 --- a/src/indexer/master-connection.c +++ b/src/indexer/master-connection.c @@ -128,9 +128,9 @@ index_mailbox_precache(struct master_connection *conn, struct mailbox *box) ret = -1; break; } - if (++counter % 100 == 0) { - percentage = counter*100 / max; - if (percentage != percentage_sent && percentage < 100) { + percentage = (++counter * 100) / max; + if (percentage > percentage_sent) { + if (percentage < 100) { percentage_sent = percentage; if (i_snprintf(percentage_str, sizeof(percentage_str), "%u\n",