Skip to content

Commit bf0b156

Browse files
committed
refactor: move mtime_on_use check up to caller
1 parent 21f4de7 commit bf0b156

File tree

1 file changed

+8
-9
lines changed
  • src/cargo/core/compiler/fingerprint

1 file changed

+8
-9
lines changed

src/cargo/core/compiler/fingerprint/mod.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1742,7 +1742,14 @@ fn compare_old_fingerprint(
17421742
mtime_on_use: bool,
17431743
forced: bool,
17441744
) -> Option<DirtyReason> {
1745-
let compare = _compare_old_fingerprint(old_hash_path, new_fingerprint, mtime_on_use);
1745+
if mtime_on_use {
1746+
// update the mtime so other cleaners know we used it
1747+
let t = FileTime::from_system_time(SystemTime::now());
1748+
debug!("mtime-on-use forcing {:?} to {}", old_hash_path, t);
1749+
paths::set_file_time_no_err(old_hash_path, t);
1750+
}
1751+
1752+
let compare = _compare_old_fingerprint(old_hash_path, new_fingerprint);
17461753
log_compare(unit, &compare);
17471754
match compare {
17481755
Ok(None) if forced => Some(DirtyReason::Forced),
@@ -1754,17 +1761,9 @@ fn compare_old_fingerprint(
17541761
fn _compare_old_fingerprint(
17551762
old_hash_path: &Path,
17561763
new_fingerprint: &Fingerprint,
1757-
mtime_on_use: bool,
17581764
) -> CargoResult<Option<DirtyReason>> {
17591765
let old_fingerprint_short = paths::read(old_hash_path)?;
17601766

1761-
if mtime_on_use {
1762-
// update the mtime so other cleaners know we used it
1763-
let t = FileTime::from_system_time(SystemTime::now());
1764-
debug!("mtime-on-use forcing {:?} to {}", old_hash_path, t);
1765-
paths::set_file_time_no_err(old_hash_path, t);
1766-
}
1767-
17681767
let new_hash = new_fingerprint.hash_u64();
17691768

17701769
if util::to_hex(new_hash) == old_fingerprint_short && new_fingerprint.fs_status.up_to_date() {

0 commit comments

Comments
 (0)