]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index: Make sure cache compression doesn't clear the file unneededly.
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 23 May 2016 15:46:09 +0000 (18:46 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 23 May 2016 20:26:34 +0000 (23:26 +0300)
This probably never happened with current code, except when the cache file
was already broken.

mail_cache_compress() unmapped cache when map_with_read==TRUE, but we never
mapped it back. This would cause cache copying code to think cache was
unusable and not copy anything.

src/lib-index/mail-cache-compress.c

index cfc33de57c85e1d2684f1955db6c351bede2acb4..66bbab4972af785d4285ad0f389f51afae9e14c8 100644 (file)
@@ -452,6 +452,9 @@ static int mail_cache_compress_locked(struct mail_cache *cache,
 
                return mail_cache_reopen(cache) < 0 ? -1 : 0;
        }
+       /* make sure we have mapped it before reading. */
+       if (mail_cache_map(cache, 0, 0, &data) < 0)
+               return -1;
 
        /* we want to recreate the cache. write it first to a temporary file */
        fd = mail_index_create_tmp_file(cache->index, cache->filepath, &temp_path);