]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imapc: Avoid duplicate FETCH BODY.PEEK[] when mail is already expunged
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 22 Feb 2018 13:55:20 +0000 (15:55 +0200)
committerAki Tuomi <aki.tuomi@dovecot.fi>
Tue, 7 Aug 2018 09:59:41 +0000 (12:59 +0300)
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

index 27a20fcb97a5df30069499102a3b144d838e3c91..23a32ab3a52bbd481a94b5a4a4178e90f3868e50 100644 (file)
@@ -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;