From: Timo Sirainen Date: Thu, 22 Feb 2018 13:55:20 +0000 (+0200) Subject: imapc: Avoid duplicate FETCH BODY.PEEK[] when mail is already expunged X-Git-Tag: 2.3.9~2238 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fdabb36505e139faf7753f3cf4c6b3cc1d2d8de7;p=thirdparty%2Fdovecot%2Fcore.git imapc: Avoid duplicate FETCH BODY.PEEK[] when mail is already expunged When the first FETCH (e.g. as part of mail_prefetch()) indicated that the mail is already expunged, there's no need to do it again. --- diff --git a/src/lib-storage/index/imapc/imapc-mail.c b/src/lib-storage/index/imapc/imapc-mail.c index 38f12db460..e7c20d22aa 100644 --- a/src/lib-storage/index/imapc/imapc-mail.c +++ b/src/lib-storage/index/imapc/imapc-mail.c @@ -310,6 +310,12 @@ imapc_mail_get_stream(struct mail *_mail, bool get_body, mail_set_aborted(_mail); return -1; } + if (_mail->expunged) { + /* We already detected that the mail is expunged. + Don't spend time trying to FETCH it again. */ + mail_set_expunged(_mail); + return -1; + } fetch_field = get_body || (data->access_part & READ_BODY) != 0 ? MAIL_FETCH_STREAM_BODY : MAIL_FETCH_STREAM_HEADER;