Don't make assumptions about Metadata based on temp_dir#622
Closed
mrkline wants to merge 1 commit intoogham:masterfrom
Closed
Don't make assumptions about Metadata based on temp_dir#622mrkline wants to merge 1 commit intoogham:masterfrom
mrkline wants to merge 1 commit intoogham:masterfrom
Conversation
55ef458 to
1258de3
Compare
Previously, exa would attempt to get the metadata for
`std::env::temp_dir`, and if fetching a certain timestamp
(e.g., creation time) failed, it would assume that the OS couldn't
produce that stamp for _any_ file. Requests to display or sort by that
timestamp would misfire the entire program.
This caused exa to make some sweeping claims that aren't true; e.g., that
Linux can't produce file creation times. The real story is that tmpfs
(the filesystem usually used for `/tmp`) can't, but other Linux
filesystems can and do. (The Rust standard library docs even mention
that `Metadata.created()` is backed by `statx()` since Linux 4.11.)
Since exa could be asked to list files from several filesystems,
let's handle metadata on a per-file basis. This patch makes File's
`*_time()` methods return an Option<Duration>
(`changed_time()` always returns None on a non-Unix system),
and prints a hyphen for files without that particular timestamp.
For example:
$ exa -lhUd --sort=created /tmp/example Cargo.toml Cargo.lock src target
Permissions Size User Date Created Name
.rw-r--r-- 0 mrkline - /tmp/example
.rw-r--r-- 25k mrkline 12 Jan 22:35 Cargo.lock
.rw-r--r-- 1.2k mrkline 12 Jan 22:35 Cargo.toml
drwxr-xr-x - mrkline 12 Jan 22:35 src
drwxr-xr-x - mrkline 12 Jan 22:46 target
1258de3 to
8b14ba9
Compare
Author
|
Ah, apparently using |
Owner
|
Thanks for your contribution, and for pointing me towards In this case, I merged another PR that took care of the temp_dir call, so I'm afraid I can't merge this one. |
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.
Previously, exa would attempt to get the metadata for
std::env::temp_dir, and if fetching a certain timestamp(e.g., creation time) failed, it would assume that the OS couldn't
produce that stamp for any file. Requests to display or sort by that
timestamp would misfire the entire program.
This caused exa to make some sweeping claims that aren't true; e.g., that
Linux can't produce file creation times. The real story is that tmpfs
(the filesystem usually used for
/tmp) can't, but other Linuxfilesystems can and do. (The Rust standard library docs even mention
that
Metadata.created()is backed bystatx()since Linux 4.11.)Since exa could be asked to list files from several filesystems,
let's handle metadata on a per-file basis. This patch makes File's
*_time()methods return an Option(
changed_time()always returns None on a non-Unix system),and prints a hyphen for files without that particular timestamp.
For example: