]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
maildir+deliver: Add all existing messages to uidlist if it doesn't exist yet.
authorTimo Sirainen <tss@iki.fi>
Fri, 7 Aug 2009 17:24:13 +0000 (13:24 -0400)
committerTimo Sirainen <tss@iki.fi>
Fri, 7 Aug 2009 17:24:13 +0000 (13:24 -0400)
--HG--
branch : HEAD

src/lib-storage/index/maildir/maildir-save.c

index 04cd28fa9598c729c2dd6cad5cf4f996fccb2590..f3454b2e71edae40ce535a964eab4655f8523734 100644 (file)
@@ -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