If dovecot.index.cache is compressed during the transaction, the new cache
fields mapping doesn't necessarily match what is in the transaction.
Fixes:
Error: Corrupted index cache file .../dovecot.index.cache: field index too large (27 >= 17)
Although there may be other cache corruption errors it also fixes.
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) {
+ /* Cache was compressed during this transaction. We can't
+ safely use the data anymore, since its fields won't match
+ cache->file_fields_map. */
+ return NULL;
+ }
+
recs = array_get(&ctx->cache_data_seq, &count);
for (i = *trans_next_idx; i < count; i++) {
if (recs[i].seq == seq) {