dovecot-2.2: lib-storage: Added FULLDIRNAME=name to mail_location.

dovecot at dovecot.org dovecot at dovecot.org
Tue Nov 5 13:12:36 EET 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/5c876ed0c3e0
changeset: 16934:5c876ed0c3e0
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Nov 05 13:12:25 2013 +0200
description:
lib-storage: Added FULLDIRNAME=name to mail_location.
The difference to DIRNAME is that the name is used also for index and
control directories.

diffstat:

 src/lib-storage/list/mailbox-list-fs.c |  25 +++++++++++++++++++------
 src/lib-storage/mailbox-list.c         |   7 ++++++-
 src/lib-storage/mailbox-list.h         |   4 ++++
 3 files changed, 29 insertions(+), 7 deletions(-)

diffs (100 lines):

diff -r 775b1e025939 -r 5c876ed0c3e0 src/lib-storage/list/mailbox-list-fs.c
--- a/src/lib-storage/list/mailbox-list-fs.c	Mon Nov 04 09:47:17 2013 +0200
+++ b/src/lib-storage/list/mailbox-list-fs.c	Tue Nov 05 13:12:25 2013 +0200
@@ -46,6 +46,20 @@
 	return '/';
 }
 
+static const char *
+fs_list_get_path_to(const struct mailbox_list_settings *set,
+		    const char *root_dir, const char *name)
+{
+	if (*set->maildir_name != '\0' && set->index_control_use_maildir_name) {
+		return t_strdup_printf("%s/%s%s/%s", root_dir,
+				       set->mailbox_dir_name, name,
+				       set->maildir_name);
+	} else {
+		return t_strdup_printf("%s/%s%s", root_dir,
+				       set->mailbox_dir_name, name);
+	}
+}
+
 static int
 fs_list_get_path(struct mailbox_list *_list, const char *name,
 		 enum mailbox_list_path_type type, const char **path_r)
@@ -78,6 +92,8 @@
 		if (set->alt_dir == NULL)
 			return 0;
 		if (*set->maildir_name != '\0') {
+			/* maildir_name is for the mailbox, caller is asking
+			   for the directory name */
 			*path_r = t_strdup_printf("%s/%s%s", set->alt_dir,
 						  set->mailbox_dir_name, name);
 			return 1;
@@ -93,8 +109,7 @@
 		break;
 	case MAILBOX_LIST_PATH_TYPE_CONTROL:
 		if (set->control_dir != NULL) {
-			*path_r = t_strdup_printf("%s/%s%s", set->control_dir,
-						  set->mailbox_dir_name, name);
+			*path_r = fs_list_get_path_to(set, set->control_dir, name);
 			return 1;
 		}
 		break;
@@ -102,16 +117,14 @@
 		if (set->index_dir != NULL) {
 			if (*set->index_dir == '\0')
 				return 0;
-			*path_r = t_strdup_printf("%s/%s%s", set->index_dir,
-						  set->mailbox_dir_name, name);
+			*path_r = fs_list_get_path_to(set, set->index_dir, name);
 			return 1;
 		}
 		break;
 	case MAILBOX_LIST_PATH_TYPE_INDEX_PRIVATE:
 		if (set->index_pvt_dir == NULL)
 			return 0;
-		*path_r = t_strdup_printf("%s/%s%s", set->index_pvt_dir,
-					  set->mailbox_dir_name, name);
+		*path_r = fs_list_get_path_to(set, set->index_pvt_dir, name);
 		return 1;
 	}
 
diff -r 775b1e025939 -r 5c876ed0c3e0 src/lib-storage/mailbox-list.c
--- a/src/lib-storage/mailbox-list.c	Mon Nov 04 09:47:17 2013 +0200
+++ b/src/lib-storage/mailbox-list.c	Tue Nov 05 13:12:25 2013 +0200
@@ -167,6 +167,8 @@
 		p_strdup(list->pool, set->mailbox_dir_name);
 	list->set.alt_dir = p_strdup(list->pool, set->alt_dir);
 	list->set.alt_dir_nocheck = set->alt_dir_nocheck;
+	list->set.index_control_use_maildir_name =
+		set->index_control_use_maildir_name;
 
 	if (*set->mailbox_dir_name == '\0')
 		list->set.mailbox_dir_name = "";
@@ -323,7 +325,10 @@
 			dest = &set_r->maildir_name;
 		else if (strcmp(key, "MAILBOXDIR") == 0)
 			dest = &set_r->mailbox_dir_name;
-		else {
+		else if (strcmp(key, "FULLDIRNAME") == 0) {
+			set_r->index_control_use_maildir_name = TRUE;
+			dest = &set_r->maildir_name;
+		} else {
 			*error_r = t_strdup_printf("Unknown setting: %s", key);
 			return -1;
 		}
diff -r 775b1e025939 -r 5c876ed0c3e0 src/lib-storage/mailbox-list.h
--- a/src/lib-storage/mailbox-list.h	Mon Nov 04 09:47:17 2013 +0200
+++ b/src/lib-storage/mailbox-list.h	Tue Nov 05 13:12:25 2013 +0200
@@ -125,6 +125,10 @@
 	bool utf8;
 	/* Don't check/create the alt-dir symlink. */
 	bool alt_dir_nocheck;
+	/* Use maildir_name also for index/control directories. This should
+	   have been the default since the beginning, but for backwards
+	   compatibility it had to be made an option. */
+	bool index_control_use_maildir_name;
 };
 
 struct mailbox_permissions {


More information about the dovecot-cvs mailing list