From: Timo Sirainen Date: Fri, 7 Aug 2009 17:24:13 +0000 (-0400) Subject: maildir+deliver: Add all existing messages to uidlist if it doesn't exist yet. X-Git-Tag: 2.0.alpha1~313 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6e4144d6bbfc21b270d12e066aae0fa1c0dc41a0;p=thirdparty%2Fdovecot%2Fcore.git maildir+deliver: Add all existing messages to uidlist if it doesn't exist yet. --HG-- branch : HEAD --- diff --git a/src/lib-storage/index/maildir/maildir-save.c b/src/lib-storage/index/maildir/maildir-save.c index 04cd28fa95..f3454b2e71 100644 --- a/src/lib-storage/index/maildir/maildir-save.c +++ b/src/lib-storage/index/maildir/maildir-save.c @@ -739,16 +739,22 @@ maildir_save_sync_index(struct maildir_save_context *ctx) ret = maildir_uidlist_lock(mbox->uidlist); i_assert(ret > 0); + if (maildir_sync_header_refresh(mbox) < 0) + return -1; + if ((ret = maildir_uidlist_refresh_fast_init(mbox->uidlist)) < 0) + return -1; + + if (ret == 0) { + /* uidlist doesn't exist. make sure all existing message + are added to uidlist first. */ + (void)maildir_storage_sync_force(mbox, 0); + } + if (maildir_sync_index_begin(mbox, NULL, &ctx->sync_ctx) < 0) return -1; ctx->keywords_sync_ctx = maildir_sync_get_keywords_sync_ctx(ctx->sync_ctx); - if (maildir_sync_header_refresh(mbox) < 0) - return -1; - if (maildir_uidlist_refresh_fast_init(mbox->uidlist) < 0) - return -1; - /* now that uidlist is locked, make sure all the existing mails have been added to index. we don't really look into the maildir, just add all the new mails listed in