]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index: Fix cache purging when index is being rebuilt
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Thu, 16 Apr 2020 12:59:24 +0000 (15:59 +0300)
committerTimo Sirainen <timo.sirainen@open-xchange.com>
Thu, 16 Apr 2020 12:59:24 +0000 (15:59 +0300)
All the messages until trans->first_new_seq no longer exist after reset.
At best they cause confusion and are ignored. They could also point to
high UIDs that the rebuilding removes, causing further corruption errors.

src/lib-index/mail-cache-purge.c

index 32f1f85c4219900dd3b6254bc78370156642c966..69cafefe80c2d819b311f85214030523cf886860 100644 (file)
@@ -293,9 +293,15 @@ mail_cache_copy(struct mail_cache *cache, struct mail_index_transaction *trans,
           removed. */
        first_new_seq = mail_cache_get_first_new_seq(view);
        message_count = mail_index_view_get_messages_count(view);
+       if (!trans->reset)
+               seq = 1;
+       else {
+               /* Index is being rebuilt. Ignore old messages. */
+               seq = trans->first_new_seq;
+       }
 
        i_array_init(ext_offsets, message_count); record_count = 0;
-       for (seq = 1; seq <= message_count; seq++) {
+       for (; seq <= message_count; seq++) {
                if (mail_index_transaction_is_expunged(trans, seq)) {
                        array_append_zero(ext_offsets);
                        continue;