]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Fixed looking up MAILBOX_METADATA_FIRST_SAVE_DATE from mailbox list...
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 20 Jan 2016 11:22:15 +0000 (13:22 +0200)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 20 Jan 2016 11:22:15 +0000 (13:22 +0200)
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.

src/lib-storage/list/mailbox-list-index-status.c

index 4921a3f704191496b6f522b18d8e27951ab35938..8b65943dfa89f30063e8b4ce4b32edc9d91f2589 100644 (file)
@@ -275,6 +275,7 @@ index_list_get_cached_first_saved(struct mailbox *box,
 {
        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 @@ index_list_get_cached_first_saved(struct mailbox *box,
                              &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;
 }