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);
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);
}
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);