]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
allow deleting selected mailbox
authorTimo Sirainen <tss@iki.fi>
Tue, 22 Apr 2003 18:49:00 +0000 (21:49 +0300)
committerTimo Sirainen <tss@iki.fi>
Tue, 22 Apr 2003 18:49:00 +0000 (21:49 +0300)
--HG--
branch : HEAD

src/imap/cmd-delete.c

index ee0ab18bb116c16eec294b01c22d21d70677113d..350f8a4cd3bcf9b0d1ededf01405a86b79b03418 100644 (file)
@@ -5,26 +5,29 @@
 
 int cmd_delete(struct client *client)
 {
-       const char *mailbox;
+       struct mailbox *mailbox;
+       const char *name;
 
        /* <mailbox> */
-       if (!client_read_string_args(client, 1, &mailbox))
+       if (!client_read_string_args(client, 1, &name))
                return FALSE;
 
-       if (strcasecmp(mailbox, "INBOX") == 0) {
+       if (strcasecmp(name, "INBOX") == 0) {
                /* INBOX can't be deleted */
                client_send_tagline(client, "NO INBOX can't be deleted.");
                return TRUE;
        }
 
-       if (client->mailbox != NULL &&
-           strcmp(client->mailbox->name, mailbox) == 0) {
-               client_send_tagline(client,
-                                   "NO Selected mailbox can't be deleted.");
-               return TRUE;
+       mailbox = client->mailbox;
+       if (mailbox != NULL && strcmp(mailbox->name, name) == 0) {
+               /* deleting selected mailbox. close it first */
+               client->mailbox = NULL;
+
+               if (!mailbox->close(mailbox))
+                       client_send_untagged_storage_error(client);
        }
 
-       if (client->storage->delete_mailbox(client->storage, mailbox))
+       if (client->storage->delete_mailbox(client->storage, name))
                client_send_tagline(client, "OK Delete completed.");
        else
                client_send_storage_error(client);