return 1;
}
+static void mail_cache_update_need_compress(struct mail_cache *cache)
+{
+ const struct mail_cache_header *hdr = cache->hdr;
+ unsigned int cont_percentage;
+ uoff_t max_del_space;
+
+ cont_percentage = hdr->continued_record_count * 100 /
+ (cache->index->map->rec_map->records_count == 0 ? 1 :
+ cache->index->map->rec_map->records_count);
+ if (cont_percentage >= MAIL_CACHE_COMPRESS_CONTINUED_PERCENTAGE &&
+ hdr->used_file_size >= MAIL_CACHE_COMPRESS_MIN_SIZE) {
+ /* too many continued rows, compress */
+ cache->need_compress_file_seq = hdr->file_seq;
+ }
+
+ /* see if we've reached the max. deleted space in file */
+ max_del_space = hdr->used_file_size / 100 *
+ MAIL_CACHE_COMPRESS_PERCENTAGE;
+ if (hdr->deleted_space >= max_del_space &&
+ hdr->used_file_size >= MAIL_CACHE_COMPRESS_MIN_SIZE)
+ cache->need_compress_file_seq = hdr->file_seq;
+}
+
static bool mail_cache_verify_header(struct mail_cache *cache)
{
const struct mail_cache_header *hdr = cache->data;
sizeof(cache->hdr_ro_copy));
}
cache->hdr = &cache->hdr_ro_copy;
+ if (offset == 0)
+ mail_cache_update_need_compress(cache);
return 0;
}
}
cache->hdr = cache->data;
+ if (offset == 0)
+ mail_cache_update_need_compress(cache);
return 0;
}
return mail_cache_lock_full(cache, FALSE, TRUE);
}
-static void mail_cache_update_need_compress(struct mail_cache *cache)
-{
- const struct mail_cache_header *hdr = cache->hdr;
- unsigned int cont_percentage;
- uoff_t max_del_space;
-
- cont_percentage = hdr->continued_record_count * 100 /
- (cache->index->map->rec_map->records_count == 0 ? 1 :
- cache->index->map->rec_map->records_count);
- if (cont_percentage >= MAIL_CACHE_COMPRESS_CONTINUED_PERCENTAGE &&
- hdr->used_file_size >= MAIL_CACHE_COMPRESS_MIN_SIZE) {
- /* too many continued rows, compress */
- cache->need_compress_file_seq = hdr->file_seq;
- }
-
- /* see if we've reached the max. deleted space in file */
- max_del_space = hdr->used_file_size / 100 *
- MAIL_CACHE_COMPRESS_PERCENTAGE;
- if (hdr->deleted_space >= max_del_space &&
- hdr->used_file_size >= MAIL_CACHE_COMPRESS_MIN_SIZE)
- cache->need_compress_file_seq = hdr->file_seq;
-}
-
int mail_cache_unlock(struct mail_cache *cache)
{
int ret = 0;
path = t_strconcat(ctx->tmpdir, "/", ctx->file_last->basename, NULL);
if (o_stream_flush(ctx->output) < 0) {
- mail_storage_set_critical(storage,
- "o_stream_flush(%s) failed: %m", path);
+ if (!mail_storage_set_error_from_errno(storage)) {
+ mail_storage_set_critical(storage,
+ "o_stream_flush(%s) failed: %m", path);
+ }
ctx->failed = TRUE;
}