changeset 9488:e47eb506eebd HEAD

maildir: Changed index/uidlist mismatch from assert-crashing to logging an error.
author Timo Sirainen <tss@iki.fi>
date Mon, 23 Nov 2009 12:19:24 -0500
parents 40a6a70b3146
children 6541fcc3bf54
files src/lib-storage/index/maildir/maildir-uidlist.c
diffstat 1 files changed, 17 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/index/maildir/maildir-uidlist.c	Mon Nov 23 11:43:46 2009 -0500
+++ b/src/lib-storage/index/maildir/maildir-uidlist.c	Mon Nov 23 12:19:24 2009 -0500
@@ -1236,16 +1236,28 @@
 
 	i_array_init(&new_records, hdr->messages_count + 64);
 	recs = array_get(&uidlist->records, &count);
-	for (i = 0, seq = 1; i < count && seq <= hdr->messages_count; i++) {
+	for (i = 0, seq = 1; i < count && seq <= hdr->messages_count; ) {
 		rec = mail_index_lookup(view, seq);
-		if (recs[i]->uid != rec->uid)
-			i_assert(recs[i]->uid < rec->uid);
-		else {
+		if (recs[i]->uid < rec->uid) {
+			/* expunged entry */
+			i++;
+		} else if (recs[i]->uid > rec->uid) {
+			i_error("%s: uid=%u exists in index, "
+				"but not in uidlist",
+				uidlist->path, rec->uid);
+			seq++;
+		} else {
 			array_append(&new_records, &recs[i], 1);
-			seq++;
+			seq++; i++;
 		}
 	}
 
+	for (; seq <= hdr->messages_count; seq++) {
+		rec = mail_index_lookup(view, seq);
+		i_error("%s: uid=%u exists in index tail, but not in uidlist",
+			uidlist->path, rec->uid);
+	}
+
 	/* drop messages expunged at the end of index */
 	while (i < count && recs[i]->uid < hdr->next_uid)
 		i++;