From: Timo Sirainen Date: Thu, 10 Sep 2020 13:21:17 +0000 (+0300) Subject: lib-storage: Avoid caching size.physical unless it's explicitly asked for X-Git-Tag: 2.3.13~153 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f4f1c0a1b698cf6e7b8e37ad4ac6092e8fefce61;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: Avoid caching size.physical unless it's explicitly asked for It's internally requested in a few places, but only as an optimization if it happens to exist. It's not important enough that it should affect caching decisions. This change becomes more important after the following changes, which cause size.physical to be added unnecessarily when filling out attachment flags. --- diff --git a/src/lib-storage/index/index-mail.c b/src/lib-storage/index/index-mail.c index f0fc37573a..d074d9ee96 100644 --- a/src/lib-storage/index/index-mail.c +++ b/src/lib-storage/index/index-mail.c @@ -590,7 +590,15 @@ int index_mail_get_physical_size(struct mail *_mail, uoff_t *size_r) struct index_mail_data *data = &mail->data; uoff_t size; - data->cache_fetch_fields |= MAIL_FETCH_PHYSICAL_SIZE; + if (_mail->lookup_abort != MAIL_LOOKUP_ABORT_NOT_IN_CACHE && + _mail->lookup_abort != MAIL_LOOKUP_ABORT_READ_MAIL) { + /* If size.physical isn't in cache yet, add it. Do this only + when the caller appears to actually want it to be cached. + We don't want to cache the size when coming in here from + i_stream_mail_try_get_cached_size() or + index_mail_get_cached_body_size(). */ + data->cache_fetch_fields |= MAIL_FETCH_PHYSICAL_SIZE; + } if (data->physical_size == (uoff_t)-1) { if (index_mail_get_cached_uoff_t(mail, MAIL_CACHE_PHYSICAL_FULL_SIZE,