changeset 19599:bf292cebbf7c

lib-storage: Fixed looking up MAILBOX_METADATA_FIRST_SAVE_DATE from mailbox list index. If the mailbox was cached as empty, we didn't check if it had since received new messages. This caused the first-save-date to be returned as nonexistent, which caused autoexpunging to not always work.
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Wed, 20 Jan 2016 13:22:15 +0200
parents 3d787df65bf5
children 5c99b32f6b28
files src/lib-storage/list/mailbox-list-index-status.c
diffstat 1 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/list/mailbox-list-index-status.c	Wed Jan 20 13:13:47 2016 +0200
+++ b/src/lib-storage/list/mailbox-list-index-status.c	Wed Jan 20 13:22:15 2016 +0200
@@ -275,6 +275,7 @@
 {
 	struct mailbox_list_index *ilist = INDEX_LIST_CONTEXT(box->list);
 	struct mail_index_view *view;
+	struct mailbox_status status;
 	const void *data;
 	bool expunged;
 	uint32_t seq;
@@ -289,6 +290,15 @@
 			      &data, &expunged);
 	if (data != NULL)
 		memcpy(first_saved_r, data, sizeof(*first_saved_r));
+	if (first_saved_r->timestamp != 0 && first_saved_r->uid == 0) {
+		/* mailbox was empty the last time we updated this.
+		   we'll need to verify if it still is. */
+		if (!mailbox_list_index_status(box->list, view, seq,
+					       STATUS_MESSAGES,
+					       &status, NULL, NULL) ||
+		    status.messages != 0)
+			first_saved_r->timestamp = 0;
+	}
 	mail_index_view_close(&view);
 	return first_saved_r->timestamp != 0 ? 1 : 0;
 }