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

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


details:   http://hg.dovecot.org/dovecot-1.1/rev/0596612675b5
changeset: 8343:0596612675b5
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 9954461eda42 -r 0596612675b5 src/imap/cmd-subscribe.c
--- a/src/imap/cmd-subscribe.c	Fri Aug 07 14:44:58 2009 -0400
+++ b/src/imap/cmd-subscribe.c	Thu Aug 13 20:45:09 2009 -0400
@@ -28,7 +28,8 @@ bool cmd_subscribe_full(struct client_co
 bool cmd_subscribe_full(struct client_command_context *cmd, bool subscribe)
 {
 	struct mail_namespace *ns;
-	const char *mailbox, *verify_name;
+	const char *mailbox, *mailbox2 = NULL, *verify_name;
+	bool unsubscribed_mailbox2;
 
 	/* <mailbox> */
 	if (!client_read_string_args(cmd, 1, &mailbox))
@@ -47,6 +48,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->namespaces,
@@ -58,9 +61,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