File tree 1 file changed +9
-3
lines changed
1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -1497,14 +1497,20 @@ impl Build {
1497
1497
let dst = dstdir. join ( src. file_name ( ) . unwrap ( ) ) ;
1498
1498
self . verbose_than ( 1 , & format ! ( "Install {:?} to {:?}" , src, dst) ) ;
1499
1499
t ! ( fs:: create_dir_all( dstdir) ) ;
1500
+ drop ( fs:: remove_file ( & dst) ) ;
1500
1501
{
1501
1502
if !src. exists ( ) {
1502
1503
panic ! ( "Error: File \" {}\" not found!" , src. display( ) ) ;
1503
1504
}
1504
- self . copy ( src, & dst) ;
1505
+ let metadata = t ! ( src. symlink_metadata( ) ) ;
1506
+ if let Err ( e) = fs:: copy ( & src, & dst) {
1507
+ panic ! ( "failed to copy `{}` to `{}`: {}" , src. display( ) , dst. display( ) , e)
1508
+ }
1509
+ t ! ( fs:: set_permissions( & dst, metadata. permissions( ) ) ) ;
1510
+ let atime = FileTime :: from_last_access_time ( & metadata) ;
1511
+ let mtime = FileTime :: from_last_modification_time ( & metadata) ;
1512
+ t ! ( filetime:: set_file_times( & dst, atime, mtime) ) ;
1505
1513
}
1506
- // NOTE: when using hard-links, this will also update the permissions on the original file.
1507
- // We never use permissions that are more restrictive than the original, so this shouldn't cause any issues.
1508
1514
chmod ( & dst, perms) ;
1509
1515
}
1510
1516
You can’t perform that action at this time.
0 commit comments