From: Timo Sirainen Date: Tue, 21 Feb 2017 12:42:01 +0000 (+0200) Subject: imap: Fix error message in failed FETCH's NO reply. X-Git-Tag: 2.3.0.rc1~2029 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=289bd999f282a307b05e6f8beef33155a50fb837;p=thirdparty%2Fdovecot%2Fcore.git imap: Fix error message in failed FETCH's NO reply. This was broken only with the new imap_fetch_failure = no-after setting. --- diff --git a/src/imap/cmd-fetch.c b/src/imap/cmd-fetch.c index 9b373a07ea..5f6626de96 100644 --- a/src/imap/cmd-fetch.c +++ b/src/imap/cmd-fetch.c @@ -228,7 +228,12 @@ static bool cmd_fetch_finish(struct imap_fetch_context *ctx, return cmd->cancel; } - errstr = mailbox_get_last_error(cmd->client->mailbox, &error); + if (ctx->error == MAIL_ERROR_NONE) + errstr = mailbox_get_last_error(cmd->client->mailbox, &error); + else { + errstr = ctx->errstr; + error = ctx->error; + } if (error == MAIL_ERROR_CONVERSION) { /* BINARY found unsupported Content-Transfer-Encoding */ tagged_reply = t_strdup_printf( diff --git a/src/imap/imap-fetch.c b/src/imap/imap-fetch.c index 9292ba93e9..40b28300d3 100644 --- a/src/imap/imap-fetch.c +++ b/src/imap/imap-fetch.c @@ -451,6 +451,12 @@ static bool imap_fetch_cur_failed(struct imap_fetch_context *ctx) if (!array_is_created(&ctx->fetch_failed_uids)) p_array_init(&ctx->fetch_failed_uids, ctx->ctx_pool, 8); seq_range_array_add(&ctx->fetch_failed_uids, ctx->state.cur_mail->uid); + + if (ctx->error == MAIL_ERROR_NONE) { + /* preserve the first error, since it may change in storage. */ + ctx->errstr = p_strdup(ctx->ctx_pool, + mailbox_get_last_error(ctx->state.cur_mail->box, &ctx->error)); + } return TRUE; } diff --git a/src/imap/imap-fetch.h b/src/imap/imap-fetch.h index 73d9d86af6..db891f8566 100644 --- a/src/imap/imap-fetch.h +++ b/src/imap/imap-fetch.h @@ -90,6 +90,9 @@ struct imap_fetch_context { struct imap_fetch_state state; ARRAY_TYPE(seq_range) fetch_failed_uids; + enum mail_error error; + const char *errstr; + bool initialized:1; bool failures:1; bool flags_have_handler:1;