]> 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 09:25:38 +0000 (12:25 +0300)
This should never happen.

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

index 17240bd1b72b37ebdfc3064ce5c8b59b23aa93fb..e4b74dcaa4e2c138d01d9bf2e0c2fa71d93a35b1 100644 (file)
@@ -39,6 +39,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 ae0d35da4834de9a0ae0d6333acc536df6e1d80d..5b029aad0374e879d5edc760ebe4ac2d46e629dc 100644 (file)
@@ -279,8 +279,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,