]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: mailbox-list - Try to get GUID from mailbox path
authorAki Tuomi <aki.tuomi@open-xchange.com>
Fri, 20 Aug 2021 11:30:46 +0000 (14:30 +0300)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Tue, 7 Sep 2021 08:38:03 +0000 (08:38 +0000)
src/lib-storage/list/mailbox-list-index-status.c

index 26c49d8f8d218b4a3509daa3156fc6d42dfb7dcc..e1d500d6bd4014742388ce94de7d947bffa6f9d1 100644 (file)
@@ -167,6 +167,18 @@ index_list_get_status(struct mailbox *box, enum mailbox_status_items items,
        return ibox->module_ctx.super.get_status(box, items, status_r);
 }
 
+/* Opportunistic function to see ïf we can extract guid from mailbox path */
+static bool index_list_get_guid_from_path(struct mailbox *box, guid_128_t guid_r)
+{
+       const char *path;
+       if (mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_MAILBOX, &path) <= 0)
+               return FALSE;
+       const char *ptr = strrchr(path, '/');
+       if (ptr == NULL)
+               return FALSE;
+       return guid_128_from_string(ptr + 1, guid_r) == 0;
+}
+
 static int
 index_list_get_cached_guid(struct mailbox *box, guid_128_t guid_r)
 {
@@ -176,6 +188,11 @@ index_list_get_cached_guid(struct mailbox *box, guid_128_t guid_r)
        uint32_t seq;
        int ret;
 
+       /* If using INDEX layout, try determine GUID from mailbox path */
+       if (!ilist->has_backing_store &&
+           index_list_get_guid_from_path(box, guid_r))
+               return 1;
+
        if (ilist->syncing) {
                /* syncing wants to know the GUID for a new mailbox. */
                return 0;