]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
doveadm: Rewrite "doveadm mailbox cache purge" to use mail_cache_compress()
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Fri, 27 Mar 2020 10:49:40 +0000 (12:49 +0200)
committerTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 15 Apr 2020 09:41:42 +0000 (12:41 +0300)
Also removed checks to verify whether the cache file existed or was usable.
Compression will create/fix the file, which is more likely to be the wanted
behavior than failing.

src/doveadm/doveadm-mail-mailbox-cache.c

index da6fc41b7a9634ca03164d49e616ec38ba3f4967..b5c21b0e56ed184d44194688ae5b90ff85dee41c 100644 (file)
@@ -328,38 +328,12 @@ static void cmd_mailbox_cache_remove_init(struct doveadm_mail_cmd_context *_ctx,
 static int cmd_mailbox_cache_purge_run_box(struct mailbox_cache_cmd_context *ctx,
                                           struct mailbox *box)
 {
-       struct mailbox_transaction_context *t =
-               mailbox_transaction_begin(box,
-                                         MAILBOX_TRANSACTION_FLAG_EXTERNAL |
-                                         ctx->ctx.transaction_flags,
-                                         "mailbox cache purge");
-       struct mail_cache *cache = t->box->cache;
-       struct mail_cache_compress_lock *lock;
-       int ret = 0;
-
-       if (mail_cache_open_and_verify(cache) < 0 ||
-           MAIL_CACHE_IS_UNUSABLE(cache)) {
-               mailbox_transaction_rollback(&t);
-               i_error("Cache is unusable");
-               ctx->ctx.exit_code = EX_TEMPFAIL;
-               return -1;
-       }
-
-       cache->need_compress_file_seq = UINT_MAX;
-       if (mail_cache_compress_forced(cache, t->itrans, &lock) < 0) {
-               mailbox_set_index_error(t->box);
+       if (mail_cache_compress(box->cache, (uint32_t)-1) < 0) {
+               mailbox_set_index_error(box);
                doveadm_mail_failed_mailbox(&ctx->ctx, box);
-               ret = -1;
-       }
-
-       if (mailbox_transaction_commit(&t) < 0) {
-               i_error("mailbox_transaction_commit() failed: %s",
-                       mailbox_get_last_internal_error(box, NULL));
-               doveadm_mail_failed_mailbox(&ctx->ctx, box);
-               ret = -1;
+               return -1;
        }
-       mail_cache_compress_unlock(&lock);
-       return ret;
+       return 0;
 }
 
 static int cmd_mailbox_cache_purge_run(struct doveadm_mail_cmd_context *_ctx,