From: Timo Sirainen Date: Fri, 17 Feb 2017 16:32:05 +0000 (+0200) Subject: imap: If SEARCH/SORT fails but returns some results, send them to client. X-Git-Tag: 2.2.28.rc1~40 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=808dfbe3471b19ae983093119976ff914bc2ae2e;p=thirdparty%2Fdovecot%2Fcore.git imap: If SEARCH/SORT fails but returns some results, send them to client. The previous error handling fixes cause SEARCH/SORT to now fail if there are any problems reading mails. This change makes the commands still return the best known results, so the IMAP client can still use them, even though they may not be entirely correct. --- diff --git a/src/imap/imap-search.c b/src/imap/imap-search.c index 2e1716481b..313d4c70c4 100644 --- a/src/imap/imap-search.c +++ b/src/imap/imap-search.c @@ -616,9 +616,14 @@ static int imap_search_deinit(struct imap_search_context *ctx) if (mailbox_search_deinit(&ctx->search_ctx) < 0) ret = -1; - if (ret == 0 && !ctx->cmd->cancel) + /* Send the result also after failing. It might have something useful, + even though it didn't fully succeed. The client should be able to + realize that there was some failure because NO is returned. */ + if (!ctx->cmd->cancel && + (ret == 0 || array_count(&ctx->result) > 0)) imap_search_send_result(ctx); - else { + + if (ret < 0 || ctx->cmd->cancel) { /* search failed */ if ((ctx->return_options & SEARCH_RETURN_SAVE) != 0) array_clear(&ctx->cmd->client->search_saved_uidset);