File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ use std::path::{Path, PathBuf};
2626use std:: process:: { Command , Stdio } ;
2727use std:: str;
2828use std:: sync:: OnceLock ;
29+ use std:: time:: SystemTime ;
2930
3031use build_helper:: ci:: { gha, CiEnv } ;
3132use build_helper:: exit;
@@ -1676,7 +1677,14 @@ impl Build {
16761677 if src == dst {
16771678 return ;
16781679 }
1679- let _ = fs:: remove_file ( dst) ;
1680+ if let Err ( e) = fs:: remove_file ( dst) {
1681+ if e. kind ( ) != io:: ErrorKind :: NotFound {
1682+ // workaround for https://github.com/rust-lang/rust/issues/127126
1683+ // if removing the file fails, attempt to rename it instead.
1684+ let now = t ! ( SystemTime :: now( ) . duration_since( SystemTime :: UNIX_EPOCH ) ) ;
1685+ let _ = fs:: rename ( dst, format ! ( "{}-{}" , dst. display( ) , now. as_nanos( ) ) ) ;
1686+ }
1687+ }
16801688 let metadata = t ! ( src. symlink_metadata( ) , format!( "src = {}" , src. display( ) ) ) ;
16811689 let mut src = src. to_path_buf ( ) ;
16821690 if metadata. file_type ( ) . is_symlink ( ) {
You can’t perform that action at this time.
0 commit comments