diff --git a/src/cargo/core/compiler/fingerprint/mod.rs b/src/cargo/core/compiler/fingerprint/mod.rs index 925123a8a10..5bbe804e913 100644 --- a/src/cargo/core/compiler/fingerprint/mod.rs +++ b/src/cargo/core/compiler/fingerprint/mod.rs @@ -1742,7 +1742,14 @@ fn compare_old_fingerprint( mtime_on_use: bool, forced: bool, ) -> Option { - let compare = _compare_old_fingerprint(old_hash_path, new_fingerprint, mtime_on_use); + if mtime_on_use { + // update the mtime so other cleaners know we used it + let t = FileTime::from_system_time(SystemTime::now()); + debug!("mtime-on-use forcing {:?} to {}", old_hash_path, t); + paths::set_file_time_no_err(old_hash_path, t); + } + + let compare = _compare_old_fingerprint(old_hash_path, new_fingerprint); log_compare(unit, &compare); match compare { Ok(None) if forced => Some(DirtyReason::Forced), @@ -1754,17 +1761,9 @@ fn compare_old_fingerprint( fn _compare_old_fingerprint( old_hash_path: &Path, new_fingerprint: &Fingerprint, - mtime_on_use: bool, ) -> CargoResult> { let old_fingerprint_short = paths::read(old_hash_path)?; - if mtime_on_use { - // update the mtime so other cleaners know we used it - let t = FileTime::from_system_time(SystemTime::now()); - debug!("mtime-on-use forcing {:?} to {}", old_hash_path, t); - paths::set_file_time_no_err(old_hash_path, t); - } - let new_hash = new_fingerprint.hash_u64(); if util::to_hex(new_hash) == old_fingerprint_short && new_fingerprint.fs_status.up_to_date() {