]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index: Add mail_cache_compress_forced()
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Sun, 29 Apr 2018 10:44:59 +0000 (13:44 +0300)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Tue, 13 Nov 2018 12:06:08 +0000 (14:06 +0200)
src/lib-index/mail-cache-compress.c
src/lib-index/mail-cache.h

index f818198c48e4ca570d7d0f566954c2153ad4327e..63007678fca569aace509d54841e169fbf76e77d 100644 (file)
@@ -432,7 +432,7 @@ static int mail_cache_compress_dotlock(struct mail_cache *cache,
        return 0;
 }
 
-static int mail_cache_compress_locked(struct mail_cache *cache,
+static int mail_cache_compress_locked(struct mail_cache *cache, bool forced,
                                      struct mail_index_transaction *trans,
                                      bool *unlock, struct dotlock **dotlock_r)
 {
@@ -451,7 +451,8 @@ static int mail_cache_compress_locked(struct mail_cache *cache,
                return -1;
        /* we've locked the cache compression now. if somebody else had just
           recreated the cache, reopen the cache and return success. */
-       if ((ret = mail_cache_compress_has_file_changed(cache)) != 0) {
+       if (!forced &&
+           (ret = mail_cache_compress_has_file_changed(cache)) != 0) {
                if (ret < 0)
                        return -1;
 
@@ -493,9 +494,10 @@ static int mail_cache_compress_locked(struct mail_cache *cache,
        return 0;
 }
 
-int mail_cache_compress(struct mail_cache *cache,
-                       struct mail_index_transaction *trans,
-                       struct mail_cache_compress_lock **lock_r)
+static int
+mail_cache_compress_full(struct mail_cache *cache, bool forced,
+                        struct mail_index_transaction *trans,
+                        struct mail_cache_compress_lock **lock_r)
 {
        struct dotlock *dotlock = NULL;
        bool unlock = FALSE;
@@ -542,7 +544,7 @@ int mail_cache_compress(struct mail_cache *cache,
                }
        }
        cache->compressing = TRUE;
-       ret = mail_cache_compress_locked(cache, trans, &unlock, &dotlock);
+       ret = mail_cache_compress_locked(cache, forced, trans, &unlock, &dotlock);
        cache->compressing = FALSE;
        if (unlock) {
                if (mail_cache_unlock(cache) < 0)
@@ -561,6 +563,20 @@ int mail_cache_compress(struct mail_cache *cache,
        return ret;
 }
 
+int mail_cache_compress(struct mail_cache *cache,
+                       struct mail_index_transaction *trans,
+                       struct mail_cache_compress_lock **lock_r)
+{
+       return mail_cache_compress_full(cache, FALSE, trans, lock_r);
+}
+
+int mail_cache_compress_forced(struct mail_cache *cache,
+                              struct mail_index_transaction *trans,
+                              struct mail_cache_compress_lock **lock_r)
+{
+       return mail_cache_compress_full(cache, TRUE, trans, lock_r);
+}
+
 void mail_cache_compress_unlock(struct mail_cache_compress_lock **_lock)
 {
        struct mail_cache_compress_lock *lock = *_lock;
index e41acff4e17b50aedeb7fa8162c7067ed1f9da0c..8777974eb9e6ea048fd88fb7038512520a50d584 100644 (file)
@@ -75,6 +75,9 @@ bool mail_cache_need_compress(struct mail_cache *cache);
 int mail_cache_compress(struct mail_cache *cache,
                        struct mail_index_transaction *trans,
                        struct mail_cache_compress_lock **lock_r);
+int mail_cache_compress_forced(struct mail_cache *cache,
+                              struct mail_index_transaction *trans,
+                              struct mail_cache_compress_lock **lock_r);
 void mail_cache_compress_unlock(struct mail_cache_compress_lock **lock);
 /* Returns TRUE if there is at least something in the cache. */
 bool mail_cache_exists(struct mail_cache *cache);