dovecot-2.2: imap: If DELETE can't succeed because mailbox has c...

dovecot at dovecot.org dovecot at dovecot.org
Sun Jun 24 20:57:39 EEST 2012


details:   http://hg.dovecot.org/dovecot-2.2/rev/e62979a15657
changeset: 14667:e62979a15657
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Jun 21 21:25:04 2012 +0300
description:
imap: If DELETE can't succeed because mailbox has children, don't give [ALREADYEXISTS] code.

diffstat:

 src/imap/cmd-delete.c |  16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)

diffs (34 lines):

diff -r 046f03b33584 -r e62979a15657 src/imap/cmd-delete.c
--- a/src/imap/cmd-delete.c	Thu Jun 21 19:12:04 2012 +0300
+++ b/src/imap/cmd-delete.c	Thu Jun 21 21:25:04 2012 +0300
@@ -8,7 +8,8 @@
 	struct client *client = cmd->client;
 	struct mail_namespace *ns;
 	struct mailbox *box;
-	const char *name;
+	const char *name, *errstr;
+	enum mail_error error;
 
 	/* <mailbox> */
 	if (!client_read_string_args(cmd, 1, &name))
@@ -32,10 +33,17 @@
 		mailbox_free(&client->mailbox);
 	}
 
-	if (mailbox_delete(box) < 0)
-		client_send_storage_error(cmd, mailbox_get_storage(box));
-	else
+	if (mailbox_delete(box) == 0)
 		client_send_tagline(cmd, "OK Delete completed.");
+	else {
+		errstr = mailbox_get_last_error(box, &error);
+		if (error != MAIL_ERROR_EXISTS)
+			client_send_storage_error(cmd, mailbox_get_storage(box));
+		else {
+			/* mailbox has children */
+			client_send_tagline(cmd, t_strdup_printf("NO %s", errstr));
+		}
+	}
 	mailbox_free(&box);
 	return TRUE;
 }


More information about the dovecot-cvs mailing list