]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: If mail_index_header.first_recent_uid shrinks, reset \Recent flags
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Tue, 18 Jul 2017 08:57:24 +0000 (11:57 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Tue, 18 Jul 2017 12:40:08 +0000 (15:40 +0300)
This should never happen.

src/lib-storage/index/index-storage.h
src/lib-storage/index/index-sync.c

index b245117b2fa9ee84821420113eb78b0fac5b8f9d..70c4a0ffd35ec3ef6201b803fab92517863a21b8 100644 (file)
@@ -40,6 +40,7 @@ struct index_mailbox_context {
 
        struct mailbox_vsize_update *vsize_update;
 
+       uint32_t recent_flags_prev_first_recent_uid;
        uint32_t recent_flags_last_check_nextuid;
 
        time_t sync_last_check;
index 6d180c46918918fe0f393fa0c28089ab442a6da8..5ba5baacc9da6875d2e1c384624f6d7f9412631b 100644 (file)
@@ -278,8 +278,17 @@ void index_sync_update_recent_count(struct mailbox *box)
        uint32_t seq1, seq2;
 
        hdr = mail_index_get_header(box->view);
+       if (hdr->first_recent_uid < ibox->recent_flags_prev_first_recent_uid) {
+               mail_storage_set_critical(box->storage,
+                       "Mailbox %s: first_recent_uid unexpectedly shrank: %u -> %u",
+                       box->vname, ibox->recent_flags_prev_first_recent_uid,
+                       hdr->first_recent_uid);
+               mailbox_recent_flags_reset(box);
+       }
+
        if (hdr->first_recent_uid > box->recent_flags_prev_uid ||
            hdr->next_uid > ibox->recent_flags_last_check_nextuid) {
+               ibox->recent_flags_prev_first_recent_uid = hdr->first_recent_uid;
                ibox->recent_flags_last_check_nextuid = hdr->next_uid;
                if (mail_index_lookup_seq_range(box->view,
                                                hdr->first_recent_uid,