# HG changeset patch # User Timo Sirainen # Date 1487349125 -7200 # Node ID 9aac2a64e5c26963cd2b12c436526d883930e551 # Parent 15e700c083c0473a48619779093686d2a8a3a5b0 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 -r 15e700c083c0 -r 9aac2a64e5c2 src/imap/imap-search.c --- a/src/imap/imap-search.c Fri Feb 17 18:30:51 2017 +0200 +++ b/src/imap/imap-search.c Fri Feb 17 18:32:05 2017 +0200 @@ -616,9 +616,14 @@ 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);