Mercurial > dovecot > core-2.2
changeset 14667:e62979a15657
imap: If DELETE can't succeed because mailbox has children, don't give [ALREADYEXISTS] code.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 21 Jun 2012 21:25:04 +0300 |
parents | 046f03b33584 |
children | 11c07ab07d39 |
files | src/imap/cmd-delete.c |
diffstat | 1 files changed, 12 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- 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; }