From e69444414a97c3ad2d22fb6237b16f497a56663c Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Tue, 21 Feb 2017 14:42:01 +0200 Subject: [PATCH] imap: Fix error message in failed FETCH's NO reply. This was broken only with the new imap_fetch_failure = no-after setting. --- src/imap/cmd-fetch.c | 7 ++++++- src/imap/imap-fetch.c | 6 ++++++ src/imap/imap-fetch.h | 3 +++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/imap/cmd-fetch.c b/src/imap/cmd-fetch.c index 739fcf218d..247f0abfb5 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 || error == MAIL_ERROR_INVALIDDATA) { /* a) BINARY found unsupported Content-Transfer-Encoding diff --git a/src/imap/imap-fetch.c b/src/imap/imap-fetch.c index 5c0657acb3..9d28c65831 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 46db48c230..d688113e5c 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; + unsigned int initialized:1; unsigned int failures:1; unsigned int flags_have_handler:1; -- 2.47.3