# HG changeset patch # User Timo Sirainen # Date 1487680921 -7200 # Node ID ed928407244b03b60c310426013f131e7c8502f9 # Parent 0f6a1fee4c7fdf16c22e9e4056b7497f526a6b27 imap: Fix error message in failed FETCH's NO reply. This was broken only with the new imap_fetch_failure = no-after setting. diff -r 0f6a1fee4c7f -r ed928407244b src/imap/cmd-fetch.c --- a/src/imap/cmd-fetch.c Tue Feb 21 15:44:09 2017 +0200 +++ b/src/imap/cmd-fetch.c Tue Feb 21 14:42:01 2017 +0200 @@ -228,7 +228,12 @@ 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 -r 0f6a1fee4c7f -r ed928407244b src/imap/imap-fetch.c --- a/src/imap/imap-fetch.c Tue Feb 21 15:44:09 2017 +0200 +++ b/src/imap/imap-fetch.c Tue Feb 21 14:42:01 2017 +0200 @@ -451,6 +451,12 @@ 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 -r 0f6a1fee4c7f -r ed928407244b src/imap/imap-fetch.h --- a/src/imap/imap-fetch.h Tue Feb 21 15:44:09 2017 +0200 +++ b/src/imap/imap-fetch.h Tue Feb 21 14:42:01 2017 +0200 @@ -90,6 +90,9 @@ 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;