Skip to content

Fall back to modified time if creation time of cached binaries is unavailable #108

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

Merged
merged 1 commit into from
Jun 18, 2023
Merged

Fall back to modified time if creation time of cached binaries is unavailable #108

merged 1 commit into from
Jun 18, 2023

Conversation

jmariondev
Copy link
Contributor

When attempting to re-run the example script from the README in a podman container (Alpine Linux 3.17) I receive the following output:

code $ ./example.rs
A random number: 15946831555454293876
code $ ./example.rs
error: creation time is not available on this platform currently

In the container ~/.cache/ is on a fuse-overlayfs, which doesn't seem to expose file creation (called "Birth") time information:

code $ stat ~/.cache/rust-script/binaries/release/example_09d44c1e4ea1d0fc4dcbb3cb
[ ... ]
Access: 2023-06-17 01:54:11.809091333 +0000
Modify: 2023-06-17 01:54:11.822424859 +0000
Change: 2023-06-17 01:54:11.829091621 +0000
 Birth: -

This seems to be introduced by the change here: ab77a62#diff-42cb6807ad74b3e201c5a7ca98b911c5fa08380e942be6e4ac5807f8377f87fcR364-R366

The issue is that this code assumes all files will have a creation time, while that's not true on Linux.

This commit makes no behavioral change if retrieving creation time is successful, but changes the error path to instead fall back to modified time if the creation time is missing (instead of erroring out).

On UNIX and its derivatives (read: Linux), the creation time of a file is not
guaranteed to exist. In case unwrapping the creation time fails, fall back to
using the modified time instead.
@fornwall fornwall merged commit e5ad128 into fornwall:main Jun 18, 2023
@fornwall
Copy link
Owner

Thanks a lot! Has now been released as version 0.29.0.

@jmariondev jmariondev deleted the no_crtime branch September 5, 2023 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants