From: Markus Valentin Date: Tue, 15 Jun 2021 10:19:00 +0000 (+0200) Subject: lib-index: Introduce MAIL_INDEX_VIEW_SYNC_FLAG_2ND_INDEX X-Git-Tag: 2.3.17~342 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1d9b391105f76c2bfbe92ff1c1fc5bc688e13410;p=thirdparty%2Fdovecot%2Fcore.git lib-index: Introduce MAIL_INDEX_VIEW_SYNC_FLAG_2ND_INDEX 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. --- diff --git a/src/lib-index/mail-index-view-sync.c b/src/lib-index/mail-index-view-sync.c index 2af33f97a9..d8a57936d6 100644 --- a/src/lib-index/mail-index-view-sync.c +++ b/src/lib-index/mail-index-view-sync.c @@ -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", diff --git a/src/lib-index/mail-index.h b/src/lib-index/mail-index.h index 577287e9fc..7f34eb52bc 100644 --- a/src/lib-index/mail-index.h +++ b/src/lib-index/mail-index.h @@ -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 {