]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imap: Fix error message in failed FETCH's NO reply.
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Tue, 21 Feb 2017 12:42:01 +0000 (14:42 +0200)
committerGitLab <gitlab@git.dovecot.net>
Tue, 21 Feb 2017 16:45:49 +0000 (18:45 +0200)
This was broken only with the new imap_fetch_failure = no-after setting.

src/imap/cmd-fetch.c
src/imap/imap-fetch.c
src/imap/imap-fetch.h

index 9b373a07ea3a83e5109979622cceabe004b3e2a4..5f6626de96fcabd4099cf75440b0c46878c1696f 100644 (file)
@@ -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(
index 9292ba93e9d7a0c28abace145a3fa37f0ca367e1..40b28300d3efde6756c25b27564d816ec6d9068f 100644 (file)
@@ -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;
 }
 
index 73d9d86af67d23259d9a71a6403d1f10e40dd09c..db891f8566c4f5ec562b64c3c2023c76f413719a 100644 (file)
@@ -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;