]> 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)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 22 Feb 2018 13:55:20 +0000 (15:55 +0200)
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 38f12db4608a689d6a624691e3a2980fc4cbf6bd..e7c20d22aa21f759170f858dfde72f5f55e6cb4a 100644 (file)
@@ -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;