]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Don't set virtual_size from index record if it's already set
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 31 May 2018 13:49:34 +0000 (16:49 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 4 Jun 2018 19:22:36 +0000 (19:22 +0000)
The existing virtual_size may be a correct one, while the one in the index
may be wrong. This will be an especially important fix with the next
commit, because it would make the existing inexact_total_sizes=FALSE wrong.

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

index 817be2776711f471dc89ffb7dafd7df737106a1d..744190a489c9017fb59cd4abdf3ebbb27d6da527 100644 (file)
@@ -453,17 +453,12 @@ static bool get_cached_msgpart_sizes(struct index_mail *mail)
 
 const uint32_t *index_mail_get_vsize_extension(struct mail *_mail)
 {
-       struct index_mail *mail = INDEX_MAIL(_mail);
        const void *idata;
        bool expunged ATTR_UNUSED;
 
        mail_index_lookup_ext(_mail->transaction->view, _mail->seq,
                              _mail->box->mail_vsize_ext_id, &idata, &expunged);
        const uint32_t *vsize = idata;
-
-       if (vsize != NULL && *vsize > 0) {
-               mail->data.virtual_size = (*vsize)-1;
-       }
        return vsize;
 }
 
@@ -478,6 +473,8 @@ bool index_mail_get_cached_virtual_size(struct index_mail *mail, uoff_t *size_r)
        const uint32_t *vsize = index_mail_get_vsize_extension(_mail);
 
        data->cache_fetch_fields |= MAIL_FETCH_VIRTUAL_SIZE;
+       if (data->virtual_size == (uoff_t)-1 && vsize != NULL && *vsize > 0)
+               data->virtual_size = (*vsize)-1;
        if (data->virtual_size == (uoff_t)-1) {
                if (index_mail_get_cached_uoff_t(mail,
                                                 MAIL_CACHE_VIRTUAL_FULL_SIZE,