changeset 20477:1173fef0844a

lib-storage: Autoexpunging should ignore nonexistent mailboxes. The check was done too late after recent changes.
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Fri, 01 Jul 2016 11:12:03 +0300
parents 35fce9a2bdfd
children 84191902a866
files src/lib-storage/mail-autoexpunge.c
diffstat 1 files changed, 7 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/mail-autoexpunge.c	Fri Jul 01 11:07:47 2016 +0300
+++ b/src/lib-storage/mail-autoexpunge.c	Fri Jul 01 11:12:03 2016 +0300
@@ -28,8 +28,13 @@
 
 	/* 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 @@
 			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);