From: Timo Sirainen Date: Fri, 27 Mar 2020 10:22:37 +0000 (+0200) Subject: lib-index: Use mail_cache_compress() where possible X-Git-Tag: 2.3.11.2~416 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fee4c1ad7ccaaf03bb70333c624d3d46722ff3a1;p=thirdparty%2Fdovecot%2Fcore.git lib-index: Use mail_cache_compress() where possible --- diff --git a/src/lib-index/mail-cache-decisions.c b/src/lib-index/mail-cache-decisions.c index 44aa057fe0..5b605afa8e 100644 --- a/src/lib-index/mail-cache-decisions.c +++ b/src/lib-index/mail-cache-decisions.c @@ -154,18 +154,11 @@ void mail_cache_decision_add(struct mail_cache_view *view, uint32_t seq, int mail_cache_decisions_copy(struct mail_cache *src, struct mail_cache *dst) { - struct mail_cache_compress_lock *lock = NULL; - if (mail_cache_open_and_verify(src) < 0) return -1; if (MAIL_CACHE_IS_UNUSABLE(src)) return 0; /* no caching decisions */ - struct mail_index_view *dest_view = mail_index_view_open(dst->index); - struct mail_index_transaction *itrans = - mail_index_transaction_begin(dest_view, - MAIL_INDEX_TRANSACTION_FLAG_EXTERNAL); - unsigned int count = 0; struct mail_cache_field *fields = mail_cache_register_get_list(src, pool_datastack_create(), &count); @@ -178,11 +171,5 @@ int mail_cache_decisions_copy(struct mail_cache *src, struct mail_cache *dst) that the fields are updated even if the cache was already created and no compression was done. */ dst->field_header_write_pending = TRUE; - int ret = mail_cache_compress_with_trans(dst, itrans, &lock); - if (lock != NULL) - mail_cache_compress_unlock(&lock); - if (mail_index_transaction_commit(&itrans) < 0) - ret = -1; - mail_index_view_close(&dest_view); - return ret; + return mail_cache_compress(dst); } diff --git a/src/lib-index/mail-cache-transaction.c b/src/lib-index/mail-cache-transaction.c index e3cec007c8..5c2301d63f 100644 --- a/src/lib-index/mail-cache-transaction.c +++ b/src/lib-index/mail-cache-transaction.c @@ -179,28 +179,13 @@ static int mail_cache_transaction_compress(struct mail_cache_transaction_ctx *ctx) { struct mail_cache *cache = ctx->cache; - struct mail_index_view *view; - struct mail_index_transaction *trans; - struct mail_cache_compress_lock *lock; - int ret; ctx->tried_compression = TRUE; cache->need_compress_file_seq = MAIL_CACHE_IS_UNUSABLE(cache) ? 0 : cache->hdr->file_seq; - view = mail_index_view_open(cache->index); - trans = mail_index_transaction_begin(view, - MAIL_INDEX_TRANSACTION_FLAG_EXTERNAL); - if (mail_cache_compress_with_trans(cache, trans, &lock) < 0) { - mail_index_transaction_rollback(&trans); - ret = -1; - } else { - ret = mail_index_transaction_commit(&trans); - if (lock != NULL) - mail_cache_compress_unlock(&lock); - } - mail_index_view_close(&view); + int ret = mail_cache_compress(cache); /* already written cache records must be forgotten, but records in memory can still be written to the new cache file */ mail_cache_transaction_forget_flushed(ctx);