dovecot-1.2: tb-extra-mailbox-sep workaround works better now.

dovecot at dovecot.org dovecot at dovecot.org
Fri Aug 14 03:45:26 EEST 2009


details:   http://hg.dovecot.org/dovecot-1.2/rev/339be408f49a
changeset: 9321:339be408f49a
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Aug 13 20:45:09 2009 -0400
description:
tb-extra-mailbox-sep workaround works better now.
Mailbox is subscribed without trailing separator. Unsubscribe tries to
remove both with and without separator.

diffstat:

1 file changed, 14 insertions(+), 3 deletions(-)
src/imap/cmd-subscribe.c |   17 ++++++++++++++---

diffs (42 lines):

diff -r 0463fc241aae -r 339be408f49a src/imap/cmd-subscribe.c
--- a/src/imap/cmd-subscribe.c	Thu Aug 13 20:21:21 2009 -0400
+++ b/src/imap/cmd-subscribe.c	Thu Aug 13 20:45:09 2009 -0400
@@ -30,7 +30,8 @@ bool cmd_subscribe_full(struct client_co
 {
 	struct mail_namespace *ns, *real_ns;
 	struct mail_storage *storage;
-	const char *mailbox, *verify_name, *real_name;
+	const char *mailbox, *mailbox2 = NULL, *verify_name, *real_name;
+	bool unsubscribed_mailbox2;
 
 	/* <mailbox> */
 	if (!client_read_string_args(cmd, 1, &mailbox))
@@ -66,6 +67,8 @@ bool cmd_subscribe_full(struct client_co
 	    mail_storage_get_hierarchy_sep(ns->storage)) {
 		/* verify the validity without the trailing '/' */
 		verify_name = t_strndup(verify_name, strlen(verify_name)-1);
+		mailbox2 = mailbox;
+		mailbox = t_strndup(mailbox, strlen(mailbox)-1);
 	}
 
 	if (have_listable_namespace_prefix(cmd->client->user->namespaces,
@@ -81,9 +84,17 @@ bool cmd_subscribe_full(struct client_co
 			return TRUE;
 	}
 
-	if (mailbox_list_set_subscribed(ns->list, mailbox, subscribe) < 0)
+	unsubscribed_mailbox2 = FALSE;
+	if (!subscribe && mailbox2 != NULL) {
+		/* try to unsubscribe both "box" and "box/" */
+		if (mailbox_list_set_subscribed(ns->list, mailbox2, FALSE) == 0)
+			unsubscribed_mailbox2 = TRUE;
+	}
+
+	if (mailbox_list_set_subscribed(ns->list, mailbox, subscribe) < 0 &&
+	    !unsubscribed_mailbox2) {
 		client_send_list_error(cmd, ns->list);
-	else {
+	} else {
 		client_send_tagline(cmd, subscribe ?
 				    "OK Subscribe completed." :
 				    "OK Unsubscribe completed.");


More information about the dovecot-cvs mailing list