Open awakecoding opened 5 years ago
I also ran into needing this functionality for a similar purpose (I have a static site generator for personal use, and if the modified timestamp isn't preserved it breaks caching for static assets that haven't changed).
I found that being able to set times was added fairly recently to the Rust std library, only in Rust 1.75.0. Check out the set_times
and related functions on File
: https://doc.rust-lang.org/std/fs/struct.File.html#method.set_times
I was only using a small subset of fs_extra
, so unfortunately this lead me to replacing fs_extra
with my own recursive copy that included the modified timestamp.
Add support for copying files while preserving timestamps (do not change the last modified time), just like the cp command -p or --preserve option: http://man7.org/linux/man-pages/man1/cp.1.html
I am currently working on a tool to reuse cargo build artifacts from the "target" directory, and it turns out that cargo checks the last modified time on files and triggers a rebuild if it changed.