From: Siavash Tavakoli Date: Thu, 4 Feb 2021 20:54:14 +0000 (+0000) Subject: lib-storage: Cache mailbox's namespace prefix if selectable X-Git-Tag: 2.3.15~407 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c452b7177ecd00eaa2b9bc233847e133da37b581;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: Cache mailbox's namespace prefix if selectable If namespace prefix is a selectable mailbox, mailbox_guid_cache_refresh should add it to cache. --- diff --git a/src/lib-storage/mailbox-guid-cache.c b/src/lib-storage/mailbox-guid-cache.c index 99c0e5b7e6..d80aa2637a 100644 --- a/src/lib-storage/mailbox-guid-cache.c +++ b/src/lib-storage/mailbox-guid-cache.c @@ -94,6 +94,24 @@ void mailbox_guid_cache_refresh(struct mailbox_list *list) continue; mailbox_guid_cache_add_mailbox(list, info); } + if ((list->ns->prefix_len > 0) && !mail_namespace_prefix_is_inbox(list->ns)) { + /* Also check if namespace prefix is a selectable mailbox + and add it to cache. Does not need to include INBOX since + it is added separately by mailbox_list_iter_init above. */ + const char *ns_vname = t_strndup(list->ns->prefix, + list->ns->prefix_len-1); + const struct mailbox_info ns_info = { + .vname = ns_vname, + .ns = list->ns, + }; + struct mailbox *box = mailbox_alloc(list, ns_vname, 0); + enum mailbox_existence existence; + if (mailbox_exists(box, FALSE, &existence) == 0 && + existence == MAILBOX_EXISTENCE_SELECT) + mailbox_guid_cache_add_mailbox(list, &ns_info); + mailbox_free(&box); + } + if (mailbox_list_iter_deinit(&ctx) < 0) list->guid_cache_errors = TRUE; }