]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: When initializing dovecot.index.pvt, don't reset it.
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 24 May 2017 08:47:54 +0000 (11:47 +0300)
committerGitLab <gitlab@git.dovecot.net>
Mon, 29 May 2017 10:59:05 +0000 (13:59 +0300)
This avoids unnecessary errors about index being reset when it was already
empty.

src/lib-storage/index/index-sync-pvt.c

index 9a1e1e07a1b8bb6c08c1e2cca42d935769dfcd9a..59683166b6aac14b8eb0e7d72d654b3bfb9f3b47 100644 (file)
@@ -156,6 +156,7 @@ index_mailbox_sync_pvt_index(struct index_mailbox_sync_pvt_context *ctx,
        uint32_t seq_shared, seq_pvt, seq_old_pvt, seq2, count_shared, uid;
        unsigned int pc_idx = 0;
        bool reset = FALSE, preserve_old_flags = FALSE, copy_shared_flags;
+       bool initial_index = FALSE;
        int ret;
 
        if (ctx->sync_ctx == NULL) {
@@ -173,6 +174,10 @@ index_mailbox_sync_pvt_index(struct index_mailbox_sync_pvt_context *ctx,
                        preserve_old_flags = TRUE;
                        t_array_init(&keywords, 32);
                }
+       } else if (hdr_pvt->uid_validity == 0 && hdr_pvt->next_uid <= 1) {
+               /* creating the initial index */
+               reset = TRUE;
+               initial_index = TRUE;
        } else {
                /* mailbox created/recreated */
                reset = TRUE;
@@ -192,7 +197,8 @@ index_mailbox_sync_pvt_index(struct index_mailbox_sync_pvt_context *ctx,
                        seq_shared = count_shared+1;
                }
        } else {
-               mail_index_reset(ctx->trans_pvt);
+               if (!initial_index)
+                       mail_index_reset(ctx->trans_pvt);
                mail_index_update_header(ctx->trans_pvt,
                        offsetof(struct mail_index_header, uid_validity),
                        &hdr_shared->uid_validity,