]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
indexer: index_mailbox_precache() - Ensure updates are sent even with few messages...
authorMarco Bettini <marco.bettini@open-xchange.com>
Mon, 6 Mar 2023 15:34:37 +0000 (15:34 +0000)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Mon, 22 May 2023 09:21:43 +0000 (09:21 +0000)
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.

src/indexer/master-connection.c

index 8a6e1f905b05e21b4b883ccf4f34c9ecb514fed4..636e26d3450ce4cbbee28dd41a1702cfd12ec86d 100644 (file)
@@ -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",