changeset 22226:56719ee6447a

lib-index: Fix cache lookups from uncommitted transactions with in-memory indexes 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].
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Tue, 13 Jun 2017 22:14:11 +0300
parents e3ebc1be3d49
children fbeea0c7629f
files src/lib-index/mail-cache-transaction.c
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-index/mail-cache-transaction.c	Tue Jun 13 21:54:00 2017 +0300
+++ b/src/lib-index/mail-cache-transaction.c	Tue Jun 13 22:14:11 2017 +0300
@@ -289,8 +289,9 @@
 	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. */