Skip to content

Commit bcbe0c0

Browse files
committed
Files modified in the past should not trigger a fingerprint change
Previously, we would bail from the fingerprint computation if the old and new mtimes had changed in *any* way. This caused some issues of rebuilding with filesystems that do not preserve nanosecond granularity (#2874).
1 parent a7c457e commit bcbe0c0

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

src/cargo/ops/cargo_rustc/fingerprint.rs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -172,13 +172,21 @@ impl Fingerprint {
172172
a, b)
173173
}
174174
}
175-
(&LocalFingerprint::MtimeBased(ref a, ref ap),
176-
&LocalFingerprint::MtimeBased(ref b, ref bp)) => {
177-
let a = a.0.lock().unwrap();
178-
let b = b.0.lock().unwrap();
179-
if *a != *b {
180-
bail!("mtime based components have changed: {:?} != {:?}, \
181-
paths are {:?} and {:?}", *a, *b, ap, bp)
175+
(&LocalFingerprint::MtimeBased(ref on_disk_mtime, ref ap),
176+
&LocalFingerprint::MtimeBased(ref previously_built_mtime, ref bp)) => {
177+
let on_disk_mtime = on_disk_mtime.0.lock().unwrap();
178+
let previously_built_mtime = previously_built_mtime.0.lock().unwrap();
179+
180+
let should_rebuild = match (*on_disk_mtime, *previously_built_mtime) {
181+
(None, None) => false,
182+
(Some(_), None) | (None, Some(_)) => true,
183+
(Some(on_disk), Some(previously_built)) => on_disk > previously_built,
184+
};
185+
186+
if should_rebuild {
187+
bail!("mtime based components have changed: previously {:?} now {:?}, \
188+
paths are {:?} and {:?}",
189+
*previously_built_mtime, *on_disk_mtime, ap, bp)
182190
}
183191
}
184192
_ => bail!("local fingerprint type has changed"),

0 commit comments

Comments
 (0)