]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index: Fix cache lookups from uncommitted transactions with in-memory indexes
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Tue, 13 Jun 2017 19:14:11 +0000 (22:14 +0300)
committerGitLab <gitlab@git.dovecot.net>
Wed, 14 Jun 2017 13:41:29 +0000 (16:41 +0300)
This especially fixes mail_get_header_stream() with imapc and
imapc_features=fetch-headers, because it works by first fetching the
specific headers and putting them to the cache transaction, then later on
relying on index_mail_get_header_stream() to get them from the transaction.
Before this fix they wouldn't be found, which triggered another unnecessary
FETCH BODY.PEEK[HEADER].

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

index c582241fe89083bacde73225fb4e045a49a5099f..6fa2727baaf9a0c5ac05d475b77b2c877b7c422b 100644 (file)
@@ -289,8 +289,9 @@ mail_cache_transaction_lookup_rec(struct mail_cache_transaction_ctx *ctx,
        const struct mail_cache_transaction_rec *recs;
        unsigned int i, count;
 
-       if (MAIL_CACHE_IS_UNUSABLE(ctx->cache) ||
-           ctx->cache_file_seq != ctx->cache->hdr->file_seq) {
+       if (!MAIL_INDEX_IS_IN_MEMORY(ctx->cache->index) &&
+           (MAIL_CACHE_IS_UNUSABLE(ctx->cache) ||
+            ctx->cache_file_seq != ctx->cache->hdr->file_seq)) {
                /* Cache was compressed during this transaction. We can't
                   safely use the data anymore, since its fields won't match
                   cache->file_fields_map. */