changeset 2714:6ed287e7a31c HEAD

Recent flag fixes
author Timo Sirainen <tss@iki.fi>
date Sat, 09 Oct 2004 16:54:28 +0300
parents e11ac6ab7470
children b81a60004612
files src/lib-storage/index/index-sync.c src/lib-storage/index/mbox/mbox-sync.c
diffstat 2 files changed, 20 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/index/index-sync.c	Sat Oct 09 00:40:05 2004 +0300
+++ b/src/lib-storage/index/index-sync.c	Sat Oct 09 16:54:28 2004 +0300
@@ -60,14 +60,26 @@
 {
 	const unsigned char *data;
 	size_t size;
-	uint32_t i, idx, count;
+	uint32_t i, idx, count, move;
+
+	if (ibox->recent_flags_start_seq == 0) {
+		/* no recent flags */
+		return;
+	}
 
-	if (seq2 < ibox->recent_flags_start_seq ||
-	    ibox->recent_flags_start_seq == 0)
+	if (seq2 < ibox->recent_flags_start_seq) {
+		/* expunging messages before recent flags, just modify
+		   the recent start position */
+		ibox->recent_flags_start_seq -= seq2 - seq1 + 1;
 		return;
+	}
 
-	if (seq1 < ibox->recent_flags_start_seq)
+	if (seq1 < ibox->recent_flags_start_seq) {
+		move = ibox->recent_flags_start_seq - seq1;
 		seq1 = ibox->recent_flags_start_seq;
+	} else {
+		move = 0;
+	}
 
 	idx = seq1 - ibox->recent_flags_start_seq;
 	count = seq2 - seq1 + 1;
@@ -86,7 +98,7 @@
 	buffer_copy(ibox->recent_flags, idx,
 		    ibox->recent_flags, idx + count, (size_t)-1);
 	buffer_set_used_size(ibox->recent_flags, size - count);
-
+        ibox->recent_flags_start_seq -= move;
 }
 
 static int index_mailbox_update_recent(struct index_mailbox *ibox,
--- a/src/lib-storage/index/mbox/mbox-sync.c	Sat Oct 09 00:40:05 2004 +0300
+++ b/src/lib-storage/index/mbox/mbox-sync.c	Sat Oct 09 16:54:28 2004 +0300
@@ -420,7 +420,9 @@
 		}
 	}
 
-	if (mail_ctx->recent)
+	if (mail_ctx->recent &&
+	    (rec == NULL || (rec->flags & MAIL_INDEX_MAIL_FLAG_DIRTY) == 0 ||
+	    (rec->flags & MAIL_RECENT) != 0))
 		index_mailbox_set_recent(sync_ctx->ibox, sync_ctx->idx_seq);
 
 	/* update from_offsets, but not if we're going to rewrite this message.