dovecot-2.0: Maildir: Make sure messages are removed from index ...

dovecot at dovecot.org dovecot at dovecot.org
Thu May 21 00:49:07 EEST 2009


details:   http://hg.dovecot.org/dovecot-2.0/rev/a4759b848d74
changeset: 9334:a4759b848d74
user:      Timo Sirainen <tss at iki.fi>
date:      Wed May 20 17:47:49 2009 -0400
description:
Maildir: Make sure messages are removed from index if they are deleted externally from new/.
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.

diffstat:

1 file changed, 13 insertions(+), 7 deletions(-)
src/lib-storage/index/maildir/maildir-sync.c |   20 +++++++++++++-------

diffs (39 lines):

diff -r 190669ac816c -r a4759b848d74 src/lib-storage/index/maildir/maildir-sync.c
--- a/src/lib-storage/index/maildir/maildir-sync.c	Wed May 20 17:30:46 2009 -0400
+++ b/src/lib-storage/index/maildir/maildir-sync.c	Wed May 20 17:47:49 2009 -0400
@@ -645,12 +645,9 @@ static void maildir_sync_update_next_uid
 	}
 }
 
-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);
 
@@ -675,9 +672,18 @@ static int maildir_sync_get_changes(stru
 	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)


More information about the dovecot-cvs mailing list