]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imapc: If imapc_list_prefix is set, don't skip it in filesystem paths.
authorTimo Sirainen <tss@iki.fi>
Sat, 1 Jun 2013 01:17:40 +0000 (04:17 +0300)
committerTimo Sirainen <tss@iki.fi>
Sat, 1 Jun 2013 01:17:40 +0000 (04:17 +0300)
Most importantly this fixes the index path when accessing the
imapc_list_prefix mailbox itself (so the indexes won't be in the mail root
dir, where they don't get deleted when mailbox is deleted).

src/lib-storage/index/imapc/imapc-list.c

index c46c2418678368290d48c8481f6590b80a3e52cb..b95df9560ea218c1a700b366aeddc0fa794837b2 100644 (file)
@@ -272,12 +272,37 @@ static const char *
 imapc_list_get_fs_name(struct imapc_mailbox_list *list, const char *name)
 {
        struct mailbox_list *fs_list = imapc_list_get_fs(list);
+       struct mail_namespace *ns = list->list.ns;
        const char *vname;
+       char ns_sep = mail_namespace_get_sep(ns);
 
        if (name == NULL)
-               return name;
+               return NULL;
 
        vname = mailbox_list_get_vname(&list->list, name);
+       if (list->storage->set->imapc_list_prefix[0] != '\0') {
+               /* put back the prefix, so it gets included in the filesystem. */
+               unsigned int vname_len = strlen(vname);
+
+               if (ns->prefix_len > 0) {
+                       /* skip over the namespace prefix */
+                       i_assert(strncmp(vname, ns->prefix, ns->prefix_len-1) == 0);
+                       if (vname_len == ns->prefix_len-1)
+                               vname = "";
+                       else {
+                               i_assert(vname[ns->prefix_len-1] == ns_sep);
+                               vname += ns->prefix_len;
+                       }
+               }
+               if (vname[0] == '\0') {
+                       vname = t_strconcat(ns->prefix,
+                               list->storage->set->imapc_list_prefix, NULL);
+               } else {
+                       vname = t_strdup_printf("%s%s%c%s", ns->prefix,
+                                               list->storage->set->imapc_list_prefix,
+                                               ns_sep, vname);
+               }
+       }
        return mailbox_list_get_storage_name(fs_list, vname);
 }