Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add timestamp preservation mode (cp -p) #22

Open
awakecoding opened this issue Feb 8, 2019 · 1 comment
Open

Add timestamp preservation mode (cp -p) #22

awakecoding opened this issue Feb 8, 2019 · 1 comment

Comments

@awakecoding
Copy link

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

       -p     same as --preserve=mode,ownership,timestamps

       --preserve[=ATTR_LIST]
              preserve the specified attributes (default:
              mode,ownership,timestamps), if possible additional attributes:
              context, links, xattr, all

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.

@JWorthe
Copy link

JWorthe commented Jun 26, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants