From: Joel Rosdahl Date: Wed, 16 Sep 2020 13:26:17 +0000 (+0200) Subject: recompress: Don’t defer updating statistics counter X-Git-Tag: v4.0~92 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=16b2a99a2b5d86b75a48c6fc28b928ba59c189e5;p=thirdparty%2Fccache.git recompress: Don’t defer updating statistics counter As of dd8f65aa558, the Context destructor no longer flushes statistics. --- diff --git a/src/compress.cpp b/src/compress.cpp index 80dc418df..bcc2d4011 100644 --- a/src/compress.cpp +++ b/src/compress.cpp @@ -152,8 +152,7 @@ create_writer(FILE* stream, } void -recompress_file(Context& ctx, - RecompressionStatistics& statistics, +recompress_file(RecompressionStatistics& statistics, const std::string& stats_file, const CacheFile& cache_file, optional level) @@ -200,13 +199,9 @@ recompress_file(Context& ctx, const size_t size_delta = (new_stat.size_on_disk() - old_stat.size_on_disk()) / 1024; - if (ctx.stats_file() == stats_file) { - ctx.counter_updates.increment(Statistic::cache_size_kibibyte, size_delta); - } else { - Statistics::update(stats_file, [=](Counters& cs) { - cs.increment(Statistic::cache_size_kibibyte, size_delta); - }); - } + Statistics::update(stats_file, [=](Counters& cs) { + cs.increment(Statistic::cache_size_kibibyte, size_delta); + }); statistics.update(content_size, old_stat.size(), new_stat.size(), 0); @@ -306,9 +301,9 @@ compress_recompress(Context& ctx, const auto& file = files[i]; if (file->type() != CacheFile::Type::unknown) { - thread_pool.enqueue([&ctx, &statistics, stats_file, file, level] { + thread_pool.enqueue([&statistics, stats_file, file, level] { try { - recompress_file(ctx, statistics, stats_file, *file, level); + recompress_file(statistics, stats_file, *file, level); } catch (Error&) { // Ignore for now. }