Skip to content

Commit

Permalink
Workaround for filesystems that round timestamps to 1-second precision
Browse files Browse the repository at this point in the history
  • Loading branch information
kornelski committed Apr 30, 2023
1 parent 0ad289b commit 4d71937
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/cargo/core/compiler/fingerprint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1888,7 +1888,19 @@ 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;

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

if fresh {
continue;
}

Expand Down

0 comments on commit 4d71937

Please sign in to comment.