]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Track INBOX UIDVALIDITY and GUID in mailbox list index
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 10 Jul 2017 10:34:17 +0000 (13:34 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 12 Jul 2017 21:40:11 +0000 (00:40 +0300)
This allows existence checks and GUID lookups for INBOX to be done from the
index.

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

index 0f4b356a6b07aa375f47e0de715f10839323de6d..b5f55fd9262cae2f3d070101e38de3a34ef04482 100644 (file)
@@ -34,7 +34,7 @@ struct index_list_storage_module index_list_storage_module =
        ((box)->inbox_any)
 
 static int
-index_list_open_view(struct mailbox *box, bool refresh,
+index_list_open_view(struct mailbox *box, bool status_check,
                     struct mail_index_view **view_r, uint32_t *seq_r)
 {
        struct mailbox_list_index *ilist = INDEX_LIST_CONTEXT(box->list);
@@ -43,7 +43,7 @@ index_list_open_view(struct mailbox *box, bool refresh,
        uint32_t seq;
        int ret;
 
-       if (MAILBOX_IS_NEVER_IN_INDEX(box))
+       if (MAILBOX_IS_NEVER_IN_INDEX(box) && status_check)
                return 0;
        if (mailbox_list_index_refresh(box->list) < 0)
                return -1;
@@ -58,7 +58,7 @@ index_list_open_view(struct mailbox *box, bool refresh,
        if (!mail_index_lookup_seq(view, node->uid, &seq)) {
                /* our in-memory tree is out of sync */
                ret = 1;
-       } else if (!refresh) {
+       } else if (!status_check) {
                /* this operation doesn't need the index to be up-to-date */
                ret = 0;
        } else T_BEGIN {
@@ -495,6 +495,12 @@ index_list_has_changed(struct mailbox *box, struct mail_index_view *list_view,
        if (!guid_128_equals(changes->guid, old_guid) &&
            !guid_128_is_empty(changes->guid))
                changes->rec_changed = TRUE;
+
+       if (MAILBOX_IS_NEVER_IN_INDEX(box)) {
+               /* check only UIDVALIDITY and GUID changes for INBOX */
+               return changes->rec_changed;
+       }
+
        changes->msgs_changed =
                old_status.messages != changes->status.messages ||
                old_status.unseen != changes->status.unseen ||
@@ -628,8 +634,6 @@ static int index_list_update_mailbox(struct mailbox *box)
                   mailbox that somebody else had just created */
                return 0;
        }
-       if (MAILBOX_IS_NEVER_IN_INDEX(box))
-               return 0;
 
        /* refresh the mailbox list index once. we can't do this again after
           locking, because it could trigger list syncing. */