From 4f1a1352a83fbb376dbd21a357d4b970b449cf9f Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Thu, 30 Jul 2009 22:07:15 -0400 Subject: [PATCH] imap: Support UID-less saves/copies after all. Virtual backend can't return them. --HG-- branch : HEAD --- src/imap/cmd-append.c | 16 ++++++++++++---- src/imap/cmd-copy.c | 9 +++++++-- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/imap/cmd-append.c b/src/imap/cmd-append.c index f879cd366a..e6e52310c5 100644 --- a/src/imap/cmd-append.c +++ b/src/imap/cmd-append.c @@ -216,6 +216,7 @@ static bool cmd_append_continue_parsing(struct client_command_context *cmd) const char *internal_date_str; time_t internal_date; int ret, timezone_offset; + unsigned int save_count; bool nonsync; if (cmd->cancel) { @@ -267,12 +268,19 @@ static bool cmd_append_continue_parsing(struct client_command_context *cmd) cmd_append_finish(ctx); return TRUE; } - i_assert(ctx->count == seq_range_count(&changes.saved_uids)); msg = t_str_new(256); - str_printfa(msg, "OK [APPENDUID %u ", changes.uid_validity); - imap_write_seq_range(msg, &changes.saved_uids); - str_append(msg, "] Append completed."); + save_count = seq_range_count(&changes.saved_uids); + if (save_count == 0) { + /* not supported by backend (virtual) */ + str_append(msg, "OK Append completed."); + } else { + i_assert(ctx->count == save_count); + str_printfa(msg, "OK [APPENDUID %u ", + changes.uid_validity); + imap_write_seq_range(msg, &changes.saved_uids); + str_append(msg, "] Append completed."); + } pool_unref(&changes.pool); if (ctx->box == cmd->client->mailbox) { diff --git a/src/imap/cmd-copy.c b/src/imap/cmd-copy.c index 7c60648287..4658a68ea8 100644 --- a/src/imap/cmd-copy.c +++ b/src/imap/cmd-copy.c @@ -146,9 +146,14 @@ bool cmd_copy(struct client_command_context *cmd) mailbox_transaction_rollback(&t); else if (mailbox_transaction_commit_get_changes(&t, &changes) < 0) ret = -1; - else if (copy_count == 0) + else if (copy_count == 0) { str_append(msg, "OK No messages copied."); - else { + pool_unref(&changes.pool); + } else if (seq_range_count(&changes.saved_uids) == 0) { + /* not supported by backend (virtual) */ + str_append(msg, "OK Copy completed."); + pool_unref(&changes.pool); + } else { i_assert(copy_count == seq_range_count(&changes.saved_uids)); str_printfa(msg, "OK [COPYUID %u %s ", changes.uid_validity, -- 2.47.3