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

dovecot at dovecot.org dovecot at dovecot.org
Fri Aug 14 03:46:02 EEST 2009


details:   http://hg.dovecot.org/dovecot-2.0/rev/f0a45d8a7984
changeset: 9788:f0a45d8a7984
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Aug 13 20:45:55 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 544a4627c81a -r f0a45d8a7984 src/imap/cmd-subscribe.c
--- a/src/imap/cmd-subscribe.c	Thu Aug 13 20:23:01 2009 -0400
+++ b/src/imap/cmd-subscribe.c	Thu Aug 13 20:45:55 2009 -0400
@@ -29,7 +29,8 @@ bool cmd_subscribe_full(struct client_co
 bool cmd_subscribe_full(struct client_command_context *cmd, bool subscribe)
 {
 	struct mail_namespace *ns, *real_ns;
-	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))
@@ -64,6 +65,8 @@ bool cmd_subscribe_full(struct client_co
 	    mailbox_list_get_hierarchy_sep(ns->list)) {
 		/* 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,
@@ -79,9 +82,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