]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Avoid index refresh with mailbox_list_index_very_dirty_syncs=yes
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 6 Jul 2017 16:00:35 +0000 (19:00 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 12 Jul 2017 21:40:11 +0000 (00:40 +0300)
src/lib-storage/list/mailbox-list-index-sync.c
src/lib-storage/list/mailbox-list-index-sync.h
src/lib-storage/list/mailbox-list-index.c

index dad5375793498586902858cfac493b2a1fa74bd4..b60b48d397aec866135756eeee1fe76d38492c38 100644 (file)
@@ -448,7 +448,7 @@ int mailbox_list_index_sync_end(struct mailbox_list_index_sync_context **_sync_c
        return ret;
 }
 
-int mailbox_list_index_sync(struct mailbox_list *list)
+int mailbox_list_index_sync(struct mailbox_list *list, bool refresh)
 {
        struct mailbox_list_index_sync_context *sync_ctx;
        int ret = 0;
@@ -456,8 +456,15 @@ int mailbox_list_index_sync(struct mailbox_list *list)
        if (mailbox_list_index_sync_begin(list, &sync_ctx) < 0)
                return -1;
 
-       if (sync_ctx->ilist->has_backing_store)
+       if (!sync_ctx->ilist->has_backing_store) {
+               /* no backing store - we have nothing to sync to */
+       } else if (refresh ||
+                  sync_ctx->ilist->call_corruption_callback ||
+                  sync_ctx->ilist->corrupted_names_or_parents ||
+                  !sync_ctx->list->mail_set->mailbox_list_index_very_dirty_syncs) {
+               /* sync the index against the backing store */
                ret = mailbox_list_index_sync_list(sync_ctx);
+       }
        return mailbox_list_index_sync_end(&sync_ctx, ret == 0);
 }
 
index 8b5815486cea4ca2b8b7bf757ae84bad49703615..e2c7674dfd0f2c172bd2b34f05c5367aa9420dc3 100644 (file)
@@ -21,7 +21,7 @@ int mailbox_list_index_sync_begin(struct mailbox_list *list,
                                  struct mailbox_list_index_sync_context **sync_ctx_r);
 int mailbox_list_index_sync_end(struct mailbox_list_index_sync_context **_sync_ctx,
                                bool success);
-int mailbox_list_index_sync(struct mailbox_list *list);
+int mailbox_list_index_sync(struct mailbox_list *list, bool refresh);
 
 /* Add name to index, return seq in index. */
 uint32_t mailbox_list_index_sync_name(struct mailbox_list_index_sync_context *ctx,
index c71fcdc21a714dadaf171990beb5630fb9c761fc..d1c63d6522886486b58c7b7eb714ba945d34f6d5 100644 (file)
@@ -504,6 +504,7 @@ int mailbox_list_index_refresh_force(struct mailbox_list *list)
        struct mailbox_list_index *ilist = INDEX_LIST_CONTEXT(list);
        struct mail_index_view *view;
        int ret;
+       bool refresh;
 
        i_assert(!ilist->syncing);
 
@@ -516,10 +517,10 @@ int mailbox_list_index_refresh_force(struct mailbox_list *list)
        }
 
        view = mail_index_view_open(ilist->index);
-       if (ilist->mailbox_tree == NULL ||
-           mailbox_list_index_need_refresh(ilist, view)) {
+       if ((refresh = mailbox_list_index_need_refresh(ilist, view)) ||
+           ilist->mailbox_tree == NULL) {
                /* refresh list of mailboxes */
-               ret = mailbox_list_index_sync(list);
+               ret = mailbox_list_index_sync(list, refresh);
        } else {
                ret = mailbox_list_index_parse(list, view, FALSE);
        }