changeset 22448:dc40c9ac739d

lib-storage: Support LISTINDEX= to disable it
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Fri, 25 Aug 2017 13:16:26 +0300
parents 7bc2a582673e
children 56e8c501d8c1
files src/lib-storage/list/mailbox-list-index.c
diffstat 1 files changed, 14 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/list/mailbox-list-index.c	Thu Jul 13 10:02:26 2017 +0300
+++ b/src/lib-storage/list/mailbox-list-index.c	Fri Aug 25 13:16:26 2017 +0300
@@ -811,6 +811,19 @@
 	return 0;
 }
 
+static bool mailbox_list_index_is_enabled(struct mailbox_list *list)
+{
+	if (!list->mail_set->mailbox_list_index)
+		return FALSE;
+	if (strcmp(list->name, MAILBOX_LIST_NAME_NONE) == 0)
+		return FALSE;
+
+	i_assert(list->set.list_index_fname != NULL);
+	if (list->set.list_index_fname[0] == '\0')
+		return FALSE;
+	return TRUE;
+}
+
 static void mailbox_list_index_created(struct mailbox_list *list)
 {
 	struct mailbox_list_vfuncs *v = list->vlast;
@@ -820,8 +833,7 @@
 	/* layout=index doesn't have any backing store */
 	has_backing_store = strcmp(list->name, MAILBOX_LIST_NAME_INDEX) != 0;
 
-	if (!list->mail_set->mailbox_list_index ||
-	    strcmp(list->name, MAILBOX_LIST_NAME_NONE) == 0) {
+	if (!mailbox_list_index_is_enabled(list)) {
 		/* reserve the module context anyway, so syncing code knows
 		   that the index is disabled */
 		i_assert(has_backing_store);