]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Avoid caching size.physical unless it's explicitly asked for
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Thu, 10 Sep 2020 13:21:17 +0000 (16:21 +0300)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Wed, 7 Oct 2020 11:43:37 +0000 (11:43 +0000)
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.

src/lib-storage/index/index-mail.c

index f0fc37573aa34ccd79b431b8647a2779d136642c..d074d9ee961d5fb6fcbebefef5d852e58dbd0bc5 100644 (file)
@@ -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,