summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Rosdahl <joel@rosdahl.net>2022-06-08 17:29:22 +0200
committerJoel Rosdahl <joel@rosdahl.net>2022-08-20 13:51:18 +0200
commit6e1653ac7334dd7cd5453594cc5bba81bb745bec (patch)
tree58ab19e74719ebff652fac635b797170809df516
parentcd717a165bc8d05fa8c18ba641be878fcdc6fbf2 (diff)
downloadccache-6e1653ac7334dd7cd5453594cc5bba81bb745bec.tar.gz
fix: Retain mtime/atime for recompressed files
(cherry picked from commit c57929acd676c577e1abae8aae6467c37ecd7b4b)
-rw-r--r--src/storage/primary/PrimaryStorage_compress.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/storage/primary/PrimaryStorage_compress.cpp b/src/storage/primary/PrimaryStorage_compress.cpp
index 4965f224..ce1e3b19 100644
--- a/src/storage/primary/PrimaryStorage_compress.cpp
+++ b/src/storage/primary/PrimaryStorage_compress.cpp
@@ -35,6 +35,7 @@
#include <core/wincompat.hpp>
#include <fmtmacros.hpp>
#include <storage/primary/StatsFile.hpp>
+#include <util/file.hpp>
#include <util/string.hpp>
#include <third_party/fmt/core.h>
@@ -188,15 +189,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());