@@ -3,6 +3,7 @@ use std::fs;
3
3
use std:: hash:: { self , Hasher } ;
4
4
use std:: path:: { Path , PathBuf } ;
5
5
use std:: sync:: { Arc , Mutex } ;
6
+ use std:: time:: SystemTime ;
6
7
7
8
use filetime:: FileTime ;
8
9
use log:: { debug, info} ;
@@ -88,6 +89,7 @@ pub fn prepare_target<'a, 'cfg>(
88
89
89
90
let root = cx. files ( ) . out_dir ( unit) ;
90
91
let missing_outputs = {
92
+ let t = FileTime :: from_system_time ( SystemTime :: now ( ) ) ;
91
93
if unit. mode . is_doc ( ) {
92
94
!root
93
95
. join ( unit. target . crate_name ( ) )
@@ -98,8 +100,15 @@ pub fn prepare_target<'a, 'cfg>(
98
100
. outputs ( unit) ?
99
101
. iter ( )
100
102
. 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
+ } ) {
103
112
None => false ,
104
113
Some ( output) => {
105
114
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
681
690
682
691
fn compare_old_fingerprint ( loc : & Path , new_fingerprint : & Fingerprint ) -> CargoResult < ( ) > {
683
692
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
+
688
698
let new_hash = new_fingerprint. hash ( ) ;
689
699
690
700
if util:: to_hex ( new_hash) == old_fingerprint_short {
0 commit comments