Skip to content

pragmatically compare timestamps (as suggested by kornelski) #13955

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

Closed
wants to merge 6 commits into from
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/cargo/core/compiler/fingerprint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1927,7 +1927,20 @@ where
// if equal, files were changed just after a previous build finished.
// Unfortunately this became problematic when (in #6484) cargo switch to more accurately
// measuring the start time of builds.
if path_mtime <= reference_mtime {
//
// Additionally, the build can span different volumes, some which support high-precision
// file timestamps and some that don't (e.g. mounted Docker volumes). This can make
// one of the timestamps lose the nanosecond part and appear up to a second in the past.
let truncated_precision =
path_mtime.nanoseconds() == 0 || reference_mtime.nanoseconds() == 0;

let fresh = if truncated_precision {
path_mtime.unix_seconds() <= reference_mtime.unix_seconds()
} else {
path_mtime <= reference_mtime
};

if fresh {
continue;
}

Expand Down