dovecot: If a message was expunged that wasn't yet even visible ...

dovecot at dovecot.org dovecot at dovecot.org
Tue Jul 17 21:19:21 EEST 2007


details:   http://hg.dovecot.org/dovecot/rev/f2ab0b7e5ae6
changeset: 6041:f2ab0b7e5ae6
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Jul 17 21:19:14 2007 +0300
description:
If a message was expunged that wasn't yet even visible to our view, it might
have still been in recent flags array. Make sure it gets removed from there.

diffstat:

1 file changed, 34 insertions(+)
src/lib-storage/index/index-sync.c |   34 ++++++++++++++++++++++++++++++++++

diffs (51 lines):

diff -r fef4aad133dd -r f2ab0b7e5ae6 src/lib-storage/index/index-sync.c
--- a/src/lib-storage/index/index-sync.c	Tue Jul 17 21:16:23 2007 +0300
+++ b/src/lib-storage/index/index-sync.c	Tue Jul 17 21:19:14 2007 +0300
@@ -258,6 +258,38 @@ int index_mailbox_sync_next(struct mailb
 	return 0;
 }
 
+static int index_mailbox_expunge_unseen_recent(struct index_mailbox *ibox)
+{
+	const struct mail_index_header *hdr;
+	uint32_t uid;
+
+	if (!array_is_created(&ibox->recent_flags))
+		return 0;
+
+	/* expunges array contained expunges for the messages that were already
+	   visible in this view, but append+expunge would be invisible.
+	   recent_flags may however contain the append UID, so we'll have to
+	   remove it separately */
+	hdr = mail_index_get_header(ibox->view);
+	if (hdr->messages_count == 0)
+		uid = 0;
+	else {
+		if (mail_index_lookup_uid(ibox->view, hdr->messages_count,
+					  &uid) < 0) {
+			mail_storage_set_index_error(ibox);
+			return -1;
+		}
+	}
+
+	if (uid + 1 < hdr->next_uid) {
+		ibox->recent_flags_count -=
+			seq_range_array_remove_range(&ibox->recent_flags,
+						     uid + 1,
+						     hdr->next_uid - 1);
+	}
+	return 0;
+}
+
 int index_mailbox_sync_deinit(struct mailbox_sync_context *_ctx,
 			      enum mailbox_status_items status_items,
 			      struct mailbox_status *status_r)
@@ -271,6 +303,8 @@ int index_mailbox_sync_deinit(struct mai
 
 	if (ctx->sync_ctx != NULL)
 		mail_index_view_sync_end(&ctx->sync_ctx);
+	if (index_mailbox_expunge_unseen_recent(ibox) < 0)
+		ret = -1;
 
 	if (ibox->keep_recent) {
 		/* mailbox syncing didn't necessarily update our recent state */


More information about the dovecot-cvs mailing list