]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
maildir: Changed index/uidlist mismatch from assert-crashing to logging an error.
authorTimo Sirainen <tss@iki.fi>
Mon, 23 Nov 2009 17:19:24 +0000 (12:19 -0500)
committerTimo Sirainen <tss@iki.fi>
Mon, 23 Nov 2009 17:19:24 +0000 (12:19 -0500)
--HG--
branch : HEAD

src/lib-storage/index/maildir/maildir-uidlist.c

index 2bba026146aca1a473611c01e882aadbd3c7cd15..58b40387adbd0540114c98d87d6df2470fc609ec 100644 (file)
@@ -1319,16 +1319,28 @@ maildir_uidlist_records_drop_expunges(struct maildir_uidlist *uidlist)
 
        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 {
-                       array_append(&new_records, &recs[i], 1);
+               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++; 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++;