File tree 1 file changed +9
-1
lines changed
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};
26
26
use std:: process:: { Command , Stdio } ;
27
27
use std:: str;
28
28
use std:: sync:: OnceLock ;
29
+ use std:: time:: SystemTime ;
29
30
30
31
use build_helper:: ci:: { gha, CiEnv } ;
31
32
use build_helper:: exit;
@@ -1676,7 +1677,14 @@ impl Build {
1676
1677
if src == dst {
1677
1678
return ;
1678
1679
}
1679
- let _ = fs:: remove_file ( dst) ;
1680
+ if fs:: remove_file ( dst) . is_err ( ) {
1681
+ // workaround for https://github.com/rust-lang/rust/issues/127126
1682
+ // if removing the file fails, attempt to rename it instead.
1683
+ let now = SystemTime :: now ( )
1684
+ . duration_since ( SystemTime :: UNIX_EPOCH )
1685
+ . expect ( "couldn't get system time" ) ;
1686
+ let _ = fs:: rename ( dst, format ! ( "{}-{}" , dst. display( ) , now. as_nanos( ) ) ) ;
1687
+ }
1680
1688
let metadata = t ! ( src. symlink_metadata( ) , format!( "src = {}" , src. display( ) ) ) ;
1681
1689
let mut src = src. to_path_buf ( ) ;
1682
1690
if metadata. file_type ( ) . is_symlink ( ) {
You can’t perform that action at this time.
0 commit comments