From: Timo Sirainen Date: Sat, 1 Jun 2013 01:17:40 +0000 (+0300) Subject: imapc: If imapc_list_prefix is set, don't skip it in filesystem paths. X-Git-Tag: 2.2.3~79 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=53e8881f41752bbef1dc2fdd7cd6730a7d065b4d;p=thirdparty%2Fdovecot%2Fcore.git imapc: If imapc_list_prefix is set, don't skip it in filesystem paths. 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). --- diff --git a/src/lib-storage/index/imapc/imapc-list.c b/src/lib-storage/index/imapc/imapc-list.c index c46c241867..b95df9560e 100644 --- a/src/lib-storage/index/imapc/imapc-list.c +++ b/src/lib-storage/index/imapc/imapc-list.c @@ -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); }