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