From: Joel Rosdahl Date: Fri, 26 Jan 2024 19:20:20 +0000 (+0100) Subject: feat: Let --inspect retain atime if possible X-Git-Tag: v4.10~116 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1c922349d736cdb47669b2388f1bbb806f1b5290;p=thirdparty%2Fccache.git feat: Let --inspect retain atime if possible For storage that relies on atime for LRU cleanup purposes, it makes sense not to affect atime when inspecting cache entries. --- diff --git a/src/core/mainoptions.cpp b/src/core/mainoptions.cpp index 6824ebd17..9ad83588c 100644 --- a/src/core/mainoptions.cpp +++ b/src/core/mainoptions.cpp @@ -210,7 +210,17 @@ read_from_path_or_stdin(const std::string& path) static int inspect_path(const std::string& path) { + std::optional orig_dir_entry; + if (path != "-") { + orig_dir_entry = util::DirEntry(path); + orig_dir_entry->refresh(); + } const auto cache_entry_data = read_from_path_or_stdin(path); + if (orig_dir_entry) { + util::set_timestamps( + path, orig_dir_entry->mtime(), orig_dir_entry->atime()); + } + if (!cache_entry_data) { PRINT(stderr, "Error: {}\n", cache_entry_data.error()); return EXIT_FAILURE;