]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: mailbox_search_notify() - Check also ctx->search_start_time
authorMarco Bettini <marco.bettini@open-xchange.com>
Mon, 13 Feb 2023 17:25:46 +0000 (17:25 +0000)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Mon, 22 May 2023 09:21:43 +0000 (09:21 +0000)
The original check caused the 1st deadline to miss being notified

src/lib-storage/mail-storage.c

index 3b39bca244c1fb663de9871d552e6787da619214..622c1b8ec456ad60dabe70bae0ac48f667ff53dd 100644 (file)
@@ -2534,22 +2534,29 @@ int mailbox_search_deinit(struct mail_search_context **_ctx)
 static void mailbox_search_notify(struct mailbox *box,
                                  struct mail_search_context *ctx)
 {
-       if (ctx->last_notify.tv_sec == 0) {
-               /* set the search time in here, in case a plugin
-                  already spent some time indexing the mailbox */
+       if (ctx->search_start_time.tv_sec == 0) {
                ctx->search_start_time = ioloop_timeval;
-       } else if (box->storage->callbacks.notify_progress != NULL &&
-                  !ctx->progress_hidden) {
-               struct mail_storage_progress_details dtl = {
-                       .total = ctx->progress_max,
-                       .processed = ctx->progress_cur,
-                       .start_time = ctx->search_start_time,
-                       .now = ioloop_timeval,
-               };
-
-               box->storage->callbacks.notify_progress(
-                       box, &dtl, box->storage->callback_context);
+               return;
        }
+
+       if (ctx->last_notify.tv_sec == 0)
+               ctx->last_notify = ctx->search_start_time;
+
+       if (box->storage->callbacks.notify_progress == NULL ||
+           ctx->progress_hidden ||
+           ioloop_time - ctx->last_notify.tv_sec < MAIL_STORAGE_NOTIFY_INTERVAL_SECS)
+               return;
+
+       struct mail_storage_progress_details dtl = {
+               .total = ctx->progress_max,
+               .processed = ctx->progress_cur,
+               .start_time = ctx->search_start_time,
+               .now = ioloop_timeval,
+       };
+
+       box->storage->callbacks.notify_progress(box, &dtl,
+                                               box->storage->callback_context);
+
        ctx->last_notify = ioloop_timeval;
 }