]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index: Add mail_cache_compress()
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Fri, 27 Mar 2020 10:19:47 +0000 (12:19 +0200)
committerTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 15 Apr 2020 09:41:42 +0000 (12:41 +0300)
src/lib-index/mail-cache-compress.c
src/lib-index/mail-cache.h

index c1100db1b4ca3705ba37171b25920307eaed83e7..c9ceaad2298840cf76bf6ec309a60defc1120fbd 100644 (file)
@@ -566,6 +566,27 @@ int mail_cache_compress_with_trans(struct mail_cache *cache,
        return mail_cache_compress_full(cache, FALSE, trans, lock_r);
 }
 
+int mail_cache_compress(struct mail_cache *cache)
+{
+       struct mail_index_view *view;
+       struct mail_index_transaction *trans;
+       struct mail_cache_compress_lock *lock;
+       int ret;
+
+       view = mail_index_view_open(cache->index);
+       trans = mail_index_transaction_begin(view,
+               MAIL_INDEX_TRANSACTION_FLAG_EXTERNAL);
+       if ((ret = mail_cache_compress_full(cache, FALSE, trans, &lock)) < 0)
+               mail_index_transaction_rollback(&trans);
+       else {
+               if (mail_index_transaction_commit(&trans) < 0)
+                       ret = -1;
+               mail_cache_compress_unlock(&lock);
+       }
+       mail_index_view_close(&view);
+       return ret;
+}
+
 int mail_cache_compress_forced(struct mail_cache *cache,
                               struct mail_index_transaction *trans,
                               struct mail_cache_compress_lock **lock_r)
index b120cbd111fead13e35b5d4690e819781dae609f..f28de80da39dbe0b2a00221958ffd52720dfeb64 100644 (file)
@@ -75,6 +75,7 @@ bool mail_cache_need_compress(struct mail_cache *cache);
 int mail_cache_compress_with_trans(struct mail_cache *cache,
                                   struct mail_index_transaction *trans,
                                   struct mail_cache_compress_lock **lock_r);
+int mail_cache_compress(struct mail_cache *cache);
 int mail_cache_compress_forced(struct mail_cache *cache,
                               struct mail_index_transaction *trans,
                               struct mail_cache_compress_lock **lock_r);