mirror of
https://github.com/rust-lang/cargo
synced 2024-10-13 03:02:45 +00:00
refactor: move mtime_on_use check up to caller
This commit is contained in:
parent
21f4de7bcf
commit
bf0b156885
|
@ -1742,7 +1742,14 @@ fn compare_old_fingerprint(
|
|||
mtime_on_use: bool,
|
||||
forced: bool,
|
||||
) -> Option<DirtyReason> {
|
||||
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<Option<DirtyReason>> {
|
||||
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() {
|
||||
|
|
Loading…
Reference in a new issue