unsigned int records_written;
bool tried_compression:1;
+ bool decisions_refreshed:1;
bool changes:1;
};
return ret;
}
+static void
+mail_cache_transaction_refresh_decisions(struct mail_cache_transaction_ctx *ctx)
+{
+ if (ctx->decisions_refreshed)
+ return;
+
+ /* Read latest caching decisions from the cache file's header once
+ per transaction. */
+ if (!ctx->cache->opened)
+ (void)mail_cache_open_and_verify(ctx->cache);
+ else
+ (void)mail_cache_header_fields_read(ctx->cache);
+ ctx->decisions_refreshed = TRUE;
+}
+
void mail_cache_add(struct mail_cache_transaction_ctx *ctx, uint32_t seq,
unsigned int field_idx, const void *data, size_t data_size)
{
/* If the cache file exists, make sure the caching decisions have been
read. */
- mail_cache_transaction_open_if_needed(ctx);
+ mail_cache_transaction_refresh_decisions(ctx);
mail_cache_decision_add(ctx->view, seq, field_idx);
{
enum mail_cache_decision_type decision;
- mail_cache_transaction_open_if_needed(ctx);
+ mail_cache_transaction_refresh_decisions(ctx);
decision = mail_cache_field_get_decision(ctx->view->cache, field_idx);
decision &= ~MAIL_CACHE_DECISION_FORCED;
{
enum mail_cache_decision_type decision;
- mail_cache_transaction_open_if_needed(ctx);
+ mail_cache_transaction_refresh_decisions(ctx);
decision = mail_cache_field_get_decision(ctx->view->cache, field_idx);
if (decision == (MAIL_CACHE_DECISION_FORCED | MAIL_CACHE_DECISION_NO))