dovecot-2.2: imapc: If imapc_list_prefix is set, don't skip it i...

dovecot at dovecot.org dovecot at dovecot.org
Sat Jun 1 04:17:50 EEST 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/7b1152c83e3e
changeset: 16444:7b1152c83e3e
user:      Timo Sirainen <tss at iki.fi>
date:      Sat Jun 01 04:17:40 2013 +0300
description:
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).

diffstat:

 src/lib-storage/index/imapc/imapc-list.c |  27 ++++++++++++++++++++++++++-
 1 files changed, 26 insertions(+), 1 deletions(-)

diffs (42 lines):

diff -r 0faaee4060c5 -r 7b1152c83e3e src/lib-storage/index/imapc/imapc-list.c
--- a/src/lib-storage/index/imapc/imapc-list.c	Sat Jun 01 04:06:48 2013 +0300
+++ b/src/lib-storage/index/imapc/imapc-list.c	Sat Jun 01 04:17:40 2013 +0300
@@ -272,12 +272,37 @@
 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);
 }
 


More information about the dovecot-cvs mailing list