]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Fix infinite loop in autoexpunging if the mails are already expunged
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Thu, 25 Mar 2021 13:34:14 +0000 (15:34 +0200)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Mon, 14 Jun 2021 21:06:36 +0000 (21:06 +0000)
This happens if the mails exist in the index, but mail_get_save_date()
fails with MAIL_ERROR_EXPUNGED.

src/lib-storage/mail-autoexpunge.c

index 44ce5dcd211ded0a4b62cf7a3afb2e2add565997..f00008d89596ca9023f1e1a2e58f595ccd010957 100644 (file)
@@ -78,7 +78,6 @@ mailbox_autoexpunge_batch(struct mailbox *box,
        mail = mail_alloc(t, 0, NULL);
 
        hdr = mail_index_get_header(box->view);
-       done = hdr->messages_count == 0;
 
        for (seq = 1; seq <= I_MIN(hdr->messages_count, AUTOEXPUNGE_BATCH_SIZE); seq++) {
                mail_set_seq(mail, seq);
@@ -118,7 +117,7 @@ mailbox_autoexpunge_batch(struct mailbox *box,
 
        if (ret < 0)
                return -1;
-       return done ? 0 : 1;
+       return (done || count == 0) ? 0 : 1;
 }
 
 static int