Mercurial > dovecot > core-2.2
changeset 5132:c4fab2513f50 HEAD
If we've a mailbox selected and we're appending to another mailbox, we got
extra FLAGS/PERMANENTFLAGS change notifications.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 15 Feb 2007 13:38:48 +0200 |
parents | 172fb23d3c8f |
children | cbc8f65d887b |
files | src/imap/cmd-append.c |
diffstat | 1 files changed, 33 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/src/imap/cmd-append.c Thu Feb 15 13:06:35 2007 +0200 +++ b/src/imap/cmd-append.c Thu Feb 15 13:38:48 2007 +0200 @@ -24,6 +24,7 @@ struct imap_parser *save_parser; struct mail_save_context *save_ctx; + struct mailbox_keywords old_keywords; unsigned int message_input:1; }; @@ -122,8 +123,12 @@ mailbox_save_cancel(&ctx->save_ctx); if (ctx->t != NULL) mailbox_transaction_rollback(&ctx->t); - if (ctx->box != ctx->cmd->client->mailbox && ctx->box != NULL) + if (ctx->box != ctx->cmd->client->mailbox && ctx->box != NULL) { mailbox_close(&ctx->box); + + pool_unref(ctx->client->keywords.pool); + ctx->client->keywords = ctx->old_keywords; + } } static bool cmd_append_continue_cancel(struct client_command_context *cmd) @@ -398,11 +403,34 @@ return box; } +static int get_keywords(struct cmd_append_context *ctx) +{ + struct client *client = ctx->client; + struct mailbox_status status; + + /* we'll need to get the current keywords so that + client_parse_mail_flags()'s keyword verification works. + however if we're not appending to selected mailbox, we'll + need to restore the keywords list. */ + if (mailbox_get_status(ctx->box, STATUS_KEYWORDS, + &status) < 0) + return -1; + + if (ctx->box != client->mailbox) { + ctx->old_keywords = client->keywords; + + memset(&client->keywords, 0, sizeof(client->keywords)); + client->keywords.pool = + pool_alloconly_create("append keywords pool", 128); + } + client_save_keywords(&client->keywords, status.keywords); + return 0; +} + bool cmd_append(struct client_command_context *cmd) { struct client *client = cmd->client; struct cmd_append_context *ctx; - struct mailbox_status status; const char *mailbox; /* <mailbox> */ @@ -419,17 +447,13 @@ if (ctx->box != NULL) { ctx->storage = mailbox_get_storage(ctx->box); - if (mailbox_get_status(ctx->box, STATUS_KEYWORDS, - &status) < 0) { + if (get_keywords(ctx) < 0) { client_send_storage_error(cmd, ctx->storage); mailbox_close(&ctx->box); } else { - client_save_keywords(&client->keywords, - status.keywords); + ctx->t = mailbox_transaction_begin(ctx->box, + MAILBOX_TRANSACTION_FLAG_EXTERNAL); } - ctx->t = ctx->box == NULL ? NULL : - mailbox_transaction_begin(ctx->box, - MAILBOX_TRANSACTION_FLAG_EXTERNAL); } io_remove(&client->io);