dovecot-2.2: virtual: Using modseq-based syncing while mailbox w...

dovecot at dovecot.org dovecot at dovecot.org
Tue Sep 16 20:23:08 UTC 2014


details:   http://hg.dovecot.org/dovecot-2.2/rev/21757e66053f
changeset: 17821:21757e66053f
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Sep 16 23:22:59 2014 +0300
description:
virtual: Using modseq-based syncing while mailbox was open didn't handle expunges correctly.
The expunges were handled only after EXPUNGE command was given, which should
have been done only for mails that no longer matched the search query but
still existed.

diffstat:

 src/plugins/virtual/virtual-sync.c |  15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)

diffs (40 lines):

diff -r 2baf1377f57a -r 21757e66053f src/plugins/virtual/virtual-sync.c
--- a/src/plugins/virtual/virtual-sync.c	Tue Sep 16 20:59:48 2014 +0300
+++ b/src/plugins/virtual/virtual-sync.c	Tue Sep 16 23:22:59 2014 +0300
@@ -720,7 +720,8 @@
 		MAILBOX_SEARCH_RESULT_FLAG_QUEUE_SYNC;
 	struct mail_index_view *view = bbox->box->view;
 	struct mail_search_result *result;
-	ARRAY_TYPE(seq_range) removed_uids, added_uids, flag_update_uids;
+	ARRAY_TYPE(seq_range) expunged_uids = ARRAY_INIT, removed_uids;
+	ARRAY_TYPE(seq_range) added_uids, flag_update_uids;
 	uint64_t modseq, old_highest_modseq;
 	uint32_t seq, uid, old_msg_count;
 
@@ -733,7 +734,15 @@
 	result = mailbox_search_result_alloc(bbox->box, bbox->search_args,
 					     result_flags);
 	mailbox_search_result_initial_done(result);
+	i_assert(array_count(&result->removed_uids) == 0);
 	virtual_sync_backend_handle_old_vmsgs(ctx, bbox, result);
+	if (array_count(&result->removed_uids) > 0) {
+		/* these are all expunged messages. treat them separately from
+		   "no longer matching messages" (=removed_uids) */
+		t_array_init(&expunged_uids, array_count(&result->removed_uids));
+		array_append_array(&expunged_uids, &result->removed_uids);
+		array_clear(&result->removed_uids);
+	}
 
 	/* get list of changed old messages (messages already once seen by
 	   virtual index), based on modseq changes. (we'll assume all modseq
@@ -766,6 +775,10 @@
 	t_array_init(&removed_uids, 128);
 	t_array_init(&added_uids, 128);
 	mailbox_search_result_sync(result, &removed_uids, &added_uids);
+	if (array_is_created(&expunged_uids)) {
+		seq_range_array_remove_seq_range(&removed_uids, &expunged_uids);
+		virtual_sync_mailbox_box_remove(ctx, bbox, &expunged_uids);
+	}
 	if (ctx->expunge_removed)
 		virtual_sync_mailbox_box_remove(ctx, bbox, &removed_uids);
 	else {


More information about the dovecot-cvs mailing list