du
/ls
: Unify file metadata time handling
#8396
Merged
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.
Was meant to be a maybe-not-that-useful refactoring, uncovered a bug in
du
...ctime
is change time, not modification time.du/test_du: Fix ctime fallback on Windows, and test
test_du: Fix --time=ctime test
It turns out
du
used to test for the wrong thing,ctime
isthe change timestamp, not creation time.
We have to rely on a regex again, as the change timestamp is the
current time.
uucore: fsext: Deduplicate metadata_get_time
Easier to just move the change time logic to another function.
uucore: fsext: Provide From<&str> helper for MetadataTimeField
We assume that the string has been validated by clap ahead of
time (just like the current code does).
du: Simplify Stat creation further
No need to have separate struct creation code for Windows and Unix.
Also remove is_dir, we can get it from metadata.
du: Keep metadata in Stat, and make use of uucore::fsext::metadata_get_time
Removes some duplicated code, with slight, but incorrect, differences.
uucore: fsext: Move metadata_get_time from ls
This function is useful for more than
ls
(du
can use it too).