changeset 21660:ed928407244b

imap: Fix error message in failed FETCH's NO reply. This was broken only with the new imap_fetch_failure = no-after setting.
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Tue, 21 Feb 2017 14:42:01 +0200
parents 0f6a1fee4c7f
children c4584d7dc07e
files src/imap/cmd-fetch.c src/imap/imap-fetch.c src/imap/imap-fetch.h
diffstat 3 files changed, 15 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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
--- 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;
 }
 
--- 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;