]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Maildir: Make sure messages are removed from index if they are deleted externally...
authorTimo Sirainen <tss@iki.fi>
Wed, 20 May 2009 21:47:49 +0000 (17:47 -0400)
committerTimo Sirainen <tss@iki.fi>
Wed, 20 May 2009 21:47:49 +0000 (17:47 -0400)
The problem happened when a message in new/ was indexed, deleted externally
and the mailbox was again opened as read-only. This caused a partial sync
in new/ directory, which didn't notice that the files were gone.

--HG--
branch : HEAD

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

index e1030d75fab48da95cae4b9263d598f3453656b2..46a4f7816178e376dc055f6a8a08431a773cb889 100644 (file)
@@ -645,13 +645,10 @@ static void maildir_sync_update_next_uid(struct maildir_mailbox *mbox)
        }
 }
 
-static bool move_recent_messages(struct maildir_sync_context *ctx)
+static bool have_recent_messages(struct maildir_sync_context *ctx)
 {
        const struct mail_index_header *hdr;
 
-       if (ctx->mbox->ibox.keep_recent)
-               return FALSE;
-
        (void)maildir_uidlist_refresh(ctx->mbox->uidlist);
 
        /* if there are files in new/, we'll need to move them. we'll check
@@ -675,9 +672,18 @@ static int maildir_sync_get_changes(struct maildir_sync_context *ctx,
        if (*new_changed_r || *cur_changed_r)
                return 1;
 
-       if (move_recent_messages(ctx)) {
-               *new_changed_r = TRUE;
-               return 1;
+       if (have_recent_messages(ctx)) {
+               if (!ctx->mbox->ibox.keep_recent) {
+                       *new_changed_r = TRUE;
+                       return 1;
+               } else if (*new_changed_r) {
+                       /* we have some recent messages and new/ has changed.
+                          if messages had been externally deleted from new/,
+                          we need to get them out of index. this requires that
+                          we make sure they weren't just moved to cur/. */
+                       *cur_changed_r = TRUE;
+                       return 1;
+               }
        }
 
        if (!ctx->mbox->ibox.keep_recent)