Skip to content

Commit 3eaa70e

Browse files
committed
just touch some of the files we use.
1 parent d25305b commit 3eaa70e

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

src/cargo/core/compiler/fingerprint.rs

+16-6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use std::fs;
33
use std::hash::{self, Hasher};
44
use std::path::{Path, PathBuf};
55
use std::sync::{Arc, Mutex};
6+
use std::time::SystemTime;
67

78
use filetime::FileTime;
89
use log::{debug, info};
@@ -88,6 +89,7 @@ pub fn prepare_target<'a, 'cfg>(
8889

8990
let root = cx.files().out_dir(unit);
9091
let missing_outputs = {
92+
let t = FileTime::from_system_time(SystemTime::now());
9193
if unit.mode.is_doc() {
9294
!root
9395
.join(unit.target.crate_name())
@@ -98,8 +100,15 @@ pub fn prepare_target<'a, 'cfg>(
98100
.outputs(unit)?
99101
.iter()
100102
.filter(|output| output.flavor != FileFlavor::DebugInfo)
101-
.find(|output| !output.path.exists())
102-
{
103+
.find(|output| {
104+
if output.path.exists() {
105+
// update the mtime so other cleaners know we used it
106+
let _ = filetime::set_file_times(&output.path, t, t);
107+
false
108+
} else {
109+
true
110+
}
111+
}) {
103112
None => false,
104113
Some(output) => {
105114
info!("missing output path {:?}", output.path);
@@ -681,10 +690,11 @@ pub fn dep_info_loc<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) -> Pa
681690

682691
fn compare_old_fingerprint(loc: &Path, new_fingerprint: &Fingerprint) -> CargoResult<()> {
683692
let old_fingerprint_short = paths::read(loc)?;
684-
let _ = paths::write(
685-
&loc.with_file_name("last-used.timestamp"),
686-
b"This file has an mtime of when cargo last used this fingerprint.",
687-
);
693+
694+
// update the mtime so other cleaners know we used it
695+
let t = FileTime::from_system_time(SystemTime::now());
696+
filetime::set_file_times(loc, t, t)?;
697+
688698
let new_hash = new_fingerprint.hash();
689699

690700
if util::to_hex(new_hash) == old_fingerprint_short {

0 commit comments

Comments
 (0)