From c57929acd676c577e1abae8aae6467c37ecd7b4b Mon Sep 17 00:00:00 2001 From: Joel Rosdahl Date: Wed, 8 Jun 2022 17:29:22 +0200 Subject: [PATCH] fix: Retain mtime/atime for recompressed files --- src/storage/primary/PrimaryStorage_compress.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/storage/primary/PrimaryStorage_compress.cpp b/src/storage/primary/PrimaryStorage_compress.cpp index 0d0adf016..24fdbb7a4 100644 --- a/src/storage/primary/PrimaryStorage_compress.cpp +++ b/src/storage/primary/PrimaryStorage_compress.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -187,15 +188,16 @@ recompress_file(RecompressionStatistics& statistics, writer->finalize(); file.close(); - atomic_new_file.commit(); - const auto new_stat = Stat::stat(cache_file.path(), Stat::OnError::log); + // Restore mtime/atime to keep cache LRU cleanup working as expected: + util::set_timestamps(cache_file.path(), old_stat.mtim(), old_stat.atim()); + + const auto new_stat = Stat::stat(cache_file.path(), Stat::OnError::log); StatsFile(stats_file).update([=](auto& cs) { cs.increment(core::Statistic::cache_size_kibibyte, Util::size_change_kibibyte(old_stat, new_stat)); }); - statistics.update(content_size, old_stat.size(), new_stat.size(), 0); LOG("Recompression of {} done", cache_file.path()); -- 2.47.3