From b31d93b7be195de632b5752e9d6627718d9890b6 Mon Sep 17 00:00:00 2001 From: Simon Quigley Date: Thu, 5 Dec 2024 01:46:26 -0600 Subject: [PATCH] Include removal of log entries equal to the age to account for rounding --- fetch-indexes-cpp/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fetch-indexes-cpp/main.cpp b/fetch-indexes-cpp/main.cpp index 60151a4..7d4e20c 100644 --- a/fetch-indexes-cpp/main.cpp +++ b/fetch-indexes-cpp/main.cpp @@ -122,13 +122,13 @@ int main(int argc, char* argv[]) { // Log rotation: Remove logs older than MAX_LOG_AGE_DAYS int maxLogAgeDays = config["MAX_LOG_AGE_DAYS"].as(); - auto now = fs::file_time_type::clock::now(); // Use the same clock as file_time_type + auto now = fs::file_time_type::clock::now(); for (const auto& entry : fs::directory_iterator(LOG_DIR)) { if (entry.is_regular_file()) { auto ftime = fs::last_write_time(entry.path()); auto age = std::chrono::duration_cast(now - ftime).count() / 24; - if (age > maxLogAgeDays) { + if (age >= maxLogAgeDays) { fs::remove(entry.path()); } }