Skip to content

Commit

Permalink
just touch some of the files we use.
Browse files Browse the repository at this point in the history
  • Loading branch information
Eh2406 committed Jan 10, 2019
1 parent d25305b commit 3eaa70e
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/cargo/core/compiler/fingerprint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::fs;
use std::hash::{self, Hasher};
use std::path::{Path, PathBuf};
use std::sync::{Arc, Mutex};
use std::time::SystemTime;

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

let root = cx.files().out_dir(unit);
let missing_outputs = {
let t = FileTime::from_system_time(SystemTime::now());
if unit.mode.is_doc() {
!root
.join(unit.target.crate_name())
Expand All @@ -98,8 +100,15 @@ pub fn prepare_target<'a, 'cfg>(
.outputs(unit)?
.iter()
.filter(|output| output.flavor != FileFlavor::DebugInfo)
.find(|output| !output.path.exists())
{
.find(|output| {
if output.path.exists() {
// update the mtime so other cleaners know we used it
let _ = filetime::set_file_times(&output.path, t, t);
false
} else {
true
}
}) {
None => false,
Some(output) => {
info!("missing output path {:?}", output.path);
Expand Down Expand Up @@ -681,10 +690,11 @@ pub fn dep_info_loc<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) -> Pa

fn compare_old_fingerprint(loc: &Path, new_fingerprint: &Fingerprint) -> CargoResult<()> {
let old_fingerprint_short = paths::read(loc)?;
let _ = paths::write(
&loc.with_file_name("last-used.timestamp"),
b"This file has an mtime of when cargo last used this fingerprint.",
);

// update the mtime so other cleaners know we used it
let t = FileTime::from_system_time(SystemTime::now());
filetime::set_file_times(loc, t, t)?;

let new_hash = new_fingerprint.hash();

if util::to_hex(new_hash) == old_fingerprint_short {
Expand Down

0 comments on commit 3eaa70e

Please sign in to comment.