]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index: Introduce MAIL_INDEX_VIEW_SYNC_FLAG_2ND_INDEX
authorMarkus Valentin <markus.valentin@open-xchange.com>
Tue, 15 Jun 2021 10:19:00 +0000 (12:19 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Fri, 2 Jul 2021 11:46:10 +0000 (11:46 +0000)
This flag is used to make sure secondary views flags-index can work
properly without emitting warnings about inconsistency. If an
inconsistency is encountered fix it by fully syncing.

src/lib-index/mail-index-view-sync.c
src/lib-index/mail-index.h

index 2af33f97a9509c6721e85a5322b75e6d3b9bd12d..d8a57936d66cea7bd5e01f1916398e499125bd68 100644 (file)
@@ -638,7 +638,18 @@ mail_index_view_sync_begin(struct mail_index_view *view,
 
        ctx->finish_min_msg_count = reset ? 0 :
                view->map->hdr.messages_count - expunge_count;
-       if (reset) {
+       if (!reset)
+               ;
+       else if ((flags & MAIL_INDEX_VIEW_SYNC_FLAG_2ND_INDEX) != 0 &&
+                view->map->hdr.messages_count == 0) {
+                       /* The secondary index is still empty, so it may have
+                          just been created for the first time. This is
+                          expected, so it shouldn't cause the view to become
+                          inconsistent. */
+                       if (mail_index_view_sync_init_fix(ctx) < 0)
+                               ctx->failed = TRUE;
+                       return ctx;
+       } else {
                view->inconsistent = TRUE;
                mail_index_set_error(view->index,
                                     "%s reset, view is now inconsistent",
index 577287e9fc803e06572dd6e698f40ec8df0baba9..7f34eb52bc8c30378a79c1620f48de349664d187 100644 (file)
@@ -247,7 +247,11 @@ enum mail_index_view_sync_flags {
        /* Make sure view isn't inconsistent after syncing. This also means
           that you don't care about view_sync_next()'s output, so it won't
           return anything. */
-       MAIL_INDEX_VIEW_SYNC_FLAG_FIX_INCONSISTENT      = 0x02
+       MAIL_INDEX_VIEW_SYNC_FLAG_FIX_INCONSISTENT      = 0x02,
+       /* Indicate that this is a secondary view, this can be used to indicate
+          that inconsistencies can be expected and if found should be fixed
+          by fully syncing. */
+       MAIL_INDEX_VIEW_SYNC_FLAG_2ND_INDEX             = 0x04,
 };
 
 struct mail_index_sync_rec {