]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imapc: Fix local state if mailbox is empty after reconnection
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Sun, 25 Mar 2018 20:15:58 +0000 (23:15 +0300)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Thu, 12 Apr 2018 06:43:18 +0000 (09:43 +0300)
If local indexes had more than 0 mails, but after reconnection the remote
IMAP server replied with "* 0 EXISTS", the mails in local index weren't
expunged. This could have resulted in:

Panic: file imapc-sync.c: line 328 (imapc_initial_sync_check): assertion failed: (mail_index_is_expunged(view, lseq) || seq_range_exists(&ctx->mbox->delayed_expunged_uids, luid))

src/lib-storage/index/imapc/imapc-mailbox.c

index 57dac046a9071a989702806ddf1bfa347e550dd5..1e381c4aa43012b7d10d09852a7a18f6f075af08 100644 (file)
@@ -220,8 +220,10 @@ imapc_mailbox_fetch_state(struct imapc_mailbox *mbox, uint32_t first_uid)
        struct imapc_command *cmd;
 
        if (mbox->exists_count == 0) {
-               /* empty mailbox - no point in fetching anything */
-               mbox->state_fetched_success = TRUE;
+               /* empty mailbox - no point in fetching anything.
+                  just make sure everything is expunged in local index. */
+               mbox->sync_next_lseq = 1;
+               imapc_mailbox_fetch_state_finish(mbox);
                return;
        }
        if (mbox->state_fetching_uid1) {