changeset 12229:da9185d1309c

lib-storage: Don't wrongly ignore subscriptions=no namespace entries.
author Timo Sirainen <tss@iki.fi>
date Fri, 01 Oct 2010 21:33:38 +0100
parents 39ef52bc4999
children a75e62340aa5
files src/lib-storage/list/mailbox-list-subscriptions.c src/lib-storage/list/subscription-file.c
diffstat 2 files changed, 15 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/list/mailbox-list-subscriptions.c	Fri Oct 01 19:09:29 2010 +0100
+++ b/src/lib-storage/list/mailbox-list-subscriptions.c	Fri Oct 01 21:33:38 2010 +0100
@@ -17,7 +17,7 @@
 	struct mailbox_list_iter_update_context update_ctx;
 	struct subsfile_list_context *subsfile_ctx;
 	struct mail_namespace *ns;
-	const char *path, *name, *name2, *full_name;
+	const char *path, *name, *name2, *full_name, *orig_name;
 	string_t *vname;
 
 	vname = str_new(default_pool, 256);
@@ -38,6 +38,7 @@
 		(ctx->flags & MAILBOX_LIST_ITER_SELECT_RECURSIVEMATCH) != 0;
 
 	while ((name = subsfile_list_next(subsfile_ctx)) != NULL) T_BEGIN {
+		orig_name = name;
 		full_name = name2 =
 			t_strconcat(default_ns->prefix, name, NULL);
 		ns = mail_namespace_find_unsubscribable(namespaces, &name2);
@@ -45,7 +46,9 @@
 			ns = default_ns;
 		else if (ns->type == NAMESPACE_SHARED &&
 			 (ns->flags & NAMESPACE_FLAG_AUTOCREATED) == 0) {
-			/* we'll need to get the namespace autocreated. */
+			/* we'll need to get the namespace autocreated.
+			   one easy way is to just ask if a mailbox name under
+			   it is valid, and it gets created */
 			(void)mailbox_list_is_valid_existing_name(ns->list,
 								  name2);
 			name = full_name;
@@ -54,8 +57,16 @@
 		} else {
 			name = name2;
 		}
-		name = mail_namespace_get_vname(ns, vname, name);
-		mailbox_list_iter_update(&update_ctx, name);
+
+		if (!mailbox_list_is_valid_existing_name(ns->list, name)) {
+			/* we'll only get into trouble if we show this */
+			i_warning("Subscriptions file %s: "
+				  "Ignoring invalid entry: %s",
+				  path, orig_name);
+		} else {
+			name = mail_namespace_get_vname(ns, vname, name);
+			mailbox_list_iter_update(&update_ctx, name);
+		}
 	} T_END;
 	str_free(&vname);
 	return subsfile_list_deinit(subsfile_ctx);
--- a/src/lib-storage/list/subscription-file.c	Fri Oct 01 19:09:29 2010 +0100
+++ b/src/lib-storage/list/subscription-file.c	Fri Oct 01 21:33:38 2010 +0100
@@ -245,14 +245,6 @@
         for (i = 0;; i++) {
                 line = next_line(ctx->list, ctx->path, ctx->input, &ctx->failed,
 				 i < SUBSCRIPTION_FILE_ESTALE_RETRY_COUNT);
-		if (line != NULL &&
-		    !mailbox_list_is_valid_existing_name(ctx->list, line)) {
-			/* we'll only get into trouble if we show this */
-			i_warning("Subscriptions file %s: "
-				  "Ignoring invalid entry: %s",
-				  ctx->path, line);
-			continue;
-		}
 		if (ctx->input->stream_errno != ESTALE ||
                     i == SUBSCRIPTION_FILE_ESTALE_RETRY_COUNT)
                         break;