]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Autoexpunging should ignore nonexistent mailboxes. release-2.2.25 17/head
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 1 Jul 2016 08:12:03 +0000 (11:12 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 1 Jul 2016 08:13:21 +0000 (11:13 +0300)
The check was done too late after recent changes.

src/lib-storage/mail-autoexpunge.c

index a9d0054043d2a50cf1b8619eca0185e5f3efa7c3..9956f866b6c219ec17d0b99eab525b29f9a0eef3 100644 (file)
@@ -28,8 +28,13 @@ mailbox_autoexpunge(struct mailbox *box, unsigned int interval_time,
 
        /* first try to check quickly from mailbox list index if we should
           bother opening this mailbox. */
-       if (mailbox_get_status(box, STATUS_MESSAGES, &status) < 0)
+       if (mailbox_get_status(box, STATUS_MESSAGES, &status) < 0) {
+               if (mailbox_get_last_mail_error(box) == MAIL_ERROR_NOTFOUND) {
+                       /* autocreated mailbox doesn't exist yet */
+                       return 0;
+               }
                return -1;
+       }
        if (interval_time == 0 && status.messages <= max_mails)
                return 0;
 
@@ -42,13 +47,8 @@ mailbox_autoexpunge(struct mailbox *box, unsigned int interval_time,
                        return 0;
        }
 
-       if (mailbox_sync(box, MAILBOX_SYNC_FLAG_FAST) < 0) {
-               if (mailbox_get_last_mail_error(box) == MAIL_ERROR_NOTFOUND) {
-                       /* autocreated mailbox doesn't exist yet */
-                       return 0;
-               }
+       if (mailbox_sync(box, MAILBOX_SYNC_FLAG_FAST) < 0)
                return -1;
-       }
 
        t = mailbox_transaction_begin(box, 0);
        mail = mail_alloc(t, 0, NULL);