From 800ed1eeabfb6477872485df7ad21a90fd9af70a Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Sat, 16 Jun 2018 15:56:26 +0300 Subject: [PATCH] imapc: Fix assert-crash when reconnecting during initial FETCH finds expunges The initial FETCH is automatically retried on failure, but the FETCH state wasn't reset during the reconnection. Fixes: 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-storage.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/lib-storage/index/imapc/imapc-storage.c b/src/lib-storage/index/imapc/imapc-storage.c index eda298151a..d7b5ba185d 100644 --- a/src/lib-storage/index/imapc/imapc-storage.c +++ b/src/lib-storage/index/imapc/imapc-storage.c @@ -619,6 +619,14 @@ static void imapc_mailbox_reopen(void *context) i_assert(!mbox->initial_sync_done); return; } + if (!mbox->initial_sync_done) { + /* Initial FETCH 1:* didn't fully succeed. We're reconnecting + and lib-imap-client is automatically resending it. But we + need to reset the sync_next_* state so that if any of the + mails are now expunged we won't get confused and crash. */ + mbox->sync_next_lseq = 1; + mbox->sync_next_rseq = 1; + } mbox->initial_sync_done = FALSE; mbox->selecting = TRUE; -- 2.47.3