fs: keep timestamps of files skipped by cpSync - #66305
Open
christianaurichzm wants to merge 1 commit into
Open
christianaurichzm wants to merge 1 commit into
christianaurichzm wants to merge 1 commit into
Conversation
With `force: false` and `preserveTimestamps: true`, the native directory copy used by `cpSync()` left existing destination files in place but still copied the source timestamps onto them. The JavaScript walk, used by `cpSync()` with a `filter` and by `fs.cp()`, leaves those files untouched. Only copy the timestamps of files that were actually copied, as is already done for their mode. Signed-off-by: Christian Aurich Zanettini Martins <christian.aurichzm@gmail.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #66305 +/- ##
==========================================
+ Coverage 90.37% 90.39% +0.01%
==========================================
Files 790 790
Lines 274279 274272 -7
Branches 52506 52512 +6
==========================================
+ Hits 247870 247915 +45
+ Misses 16890 16837 -53
- Partials 9519 9520 +1
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With
force: falseandpreserveTimestamps: true,cpSync()updates the timestamps of an existing destination file even though the file itself is skipped.This only affects the C++ recursive copy path used by
cpSync()without afilter. The JS paths used with afilter,fs.cp(), andfs.promises.cp()already leave skipped files untouched.In
CopyDirRecursive(),copy_file()returnsfalsewhenskip_existingcauses the copy to be skipped. The mode restoration already checks that return value, butCopyUtimes()did not.Only copy timestamps when the file was actually copied.
The test covers both the C++ path and the
filterpath. It fails on main and passes with this change.make lintandtest-fs-*pass on x64 Linux. v22.x is affected as well.#65547 touches the same loop, but skipped files still leave
copiedasfalse, so this change applies cleanly on top of it.