From 1333d1d42de5c920ee4d338f3f4b72e4bbe04bd5 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Thu, 22 Feb 2018 15:55:20 +0200 Subject: [PATCH] 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. --- src/lib-storage/index/imapc/imapc-mail.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/lib-storage/index/imapc/imapc-mail.c b/src/lib-storage/index/imapc/imapc-mail.c index 27a20fcb97..23a32ab3a5 100644 --- a/src/lib-storage/index/imapc/imapc-mail.c +++ b/src/lib-storage/index/imapc/imapc-mail.c @@ -312,6 +312,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;