changeset 22458:83f93173dadb

lib-storage: If ITERINDEX is set, delay checking whether mail root exists In future this could be done even without ITERINDEX. It's not done yet, since it might break backwards compatibility with some systems.
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Mon, 24 Jul 2017 20:48:25 +0300
parents 5de2bae83c93
children d802f801c8f9
files src/lib-storage/mail-storage.c
diffstat 1 files changed, 7 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/mail-storage.c	Mon Sep 04 17:48:52 2017 +0300
+++ b/src/lib-storage/mail-storage.c	Mon Jul 24 20:48:25 2017 +0300
@@ -286,24 +286,18 @@
 	}
 
 	autocreate = (flags & MAIL_STORAGE_FLAG_NO_AUTOCREATE) == 0;
+	if (autocreate && list->set.iter_from_index_dir) {
+		/* If the directories don't exist, we'll just autocreate them
+		   later. FIXME: Make this the default in v2.3 even when
+		   ITERINDEX isn't used. */
+		return 0;
+	}
 	ret = mail_storage_verify_root(root_dir, type_name, autocreate, error_r);
 	if (ret == 0) {
-		const char *mail_root_dir;
-
-		if (!list->set.iter_from_index_dir)
-			mail_root_dir = root_dir;
-		else if (!mailbox_list_get_root_path(list,
-				MAILBOX_LIST_PATH_TYPE_MAILBOX, &mail_root_dir))
-			i_unreached();
-		ret = mailbox_list_try_mkdir_root(list, mail_root_dir,
+		ret = mailbox_list_try_mkdir_root(list, root_dir,
 						  MAILBOX_LIST_PATH_TYPE_MAILBOX,
 						  error_r);
 	}
-	if (ret == 0 && list->set.iter_from_index_dir) {
-		ret = mailbox_list_try_mkdir_root(list, root_dir,
-						  MAILBOX_LIST_PATH_TYPE_INDEX,
-						  error_r);
-	}
 	return ret < 0 ? -1 : 0;
 }