diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 09:51:24 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 09:51:24 +0000 |
commit | f7548d6d28c313cf80e6f3ef89aed16a19815df1 (patch) | |
tree | a3f6f2a3f247293bee59ecd28e8cd8ceb6ca064a /src/imap/cmd-close.c | |
parent | Initial commit. (diff) | |
download | dovecot-f7548d6d28c313cf80e6f3ef89aed16a19815df1.tar.xz dovecot-f7548d6d28c313cf80e6f3ef89aed16a19815df1.zip |
Adding upstream version 1:2.3.19.1+dfsg1.upstream/1%2.3.19.1+dfsg1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/imap/cmd-close.c')
-rw-r--r-- | src/imap/cmd-close.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/imap/cmd-close.c b/src/imap/cmd-close.c new file mode 100644 index 0000000..1f4dfeb --- /dev/null +++ b/src/imap/cmd-close.c @@ -0,0 +1,36 @@ +/* Copyright (c) 2002-2018 Dovecot authors, see the included COPYING file */ + +#include "imap-common.h" +#include "imap-commands.h" +#include "imap-expunge.h" + +bool cmd_close(struct client_command_context *cmd) +{ + struct client *client = cmd->client; + struct mailbox *mailbox = client->mailbox; + struct mail_storage *storage; + const char *errstr, *tagged_reply = "OK Close completed."; + enum mail_error error = MAIL_ERROR_NONE; + + if (!client_verify_open_mailbox(cmd)) + return TRUE; + + i_assert(client->mailbox_change_lock == NULL); + + storage = mailbox_get_storage(mailbox); + if (imap_expunge(mailbox, NULL, &client->expunged_count) < 0) { + errstr = mailbox_get_last_error(mailbox, &error); + if (error != MAIL_ERROR_PERM) + client_send_untagged_storage_error(client, storage); + else { + tagged_reply = t_strdup_printf( + "OK Closed without expunging: %s", errstr); + } + } + if (mailbox_sync(mailbox, 0) < 0) + client_send_untagged_storage_error(client, storage); + + imap_client_close_mailbox(client); + client_send_tagline(cmd, tagged_reply); + return TRUE; +} |