From: Joel Rosdahl Date: Sat, 12 Sep 2020 14:02:24 +0000 (+0200) Subject: Remove knowledge about legacy top-level stats file X-Git-Tag: v4.0~98 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=800de2fbc750aa89da8f8939e915921687bfa1cc;p=thirdparty%2Fccache.git Remove knowledge about legacy top-level stats file The top-level stats file was removed in ccache 3.1 ten years ago so it seems reasonable to remove knowledge about it now. --- diff --git a/src/stats.cpp b/src/stats.cpp index a6d6129f0..729ae2957 100644 --- a/src/stats.cpp +++ b/src/stats.cpp @@ -169,20 +169,14 @@ stats_collect(const Config& config, Counters& counters, time_t* last_updated) *last_updated = 0; // Add up the stats in each directory. - for (int dir = -1; dir <= 0xF; dir++) { - std::string fname; - - if (dir == -1) { - fname = config.cache_dir() + "/stats"; - } else { - fname = fmt::format("{}/{:x}/stats", config.cache_dir(), dir); - } + for (size_t dir = 0; dir <= 0xF; ++dir) { + const auto path = fmt::format("{}/{:x}/stats", config.cache_dir(), dir); counters.set(Statistic::stats_zeroed_timestamp, 0); // Don't add - counters.increment(Statistics::read(fname)); + counters.increment(Statistics::read(path)); zero_timestamp = std::max(counters.get(Statistic::stats_zeroed_timestamp), zero_timestamp); - *last_updated = std::max(*last_updated, Stat::stat(fname).mtime()); + *last_updated = std::max(*last_updated, Stat::stat(path).mtime()); } counters.set(Statistic::stats_zeroed_timestamp, zero_timestamp); @@ -272,9 +266,6 @@ stats_print(const Config& config) void stats_zero(const Context& ctx) { - // Remove old legacy stats file at cache top directory. - Util::unlink_safe(ctx.config.cache_dir() + "/stats"); - time_t timestamp = time(nullptr); for (int dir = 0; dir <= 0xF; dir++) {