@@ -736,18 +736,6 @@ fn perform_backup(to: &Path, b: &Behavior) -> UResult<Option<PathBuf>> {
736
736
}
737
737
}
738
738
739
- fn copy_file_source_not_dev_null ( from : & Path , to : & Path ) -> io:: Result < ( ) > {
740
- let dest_meta_res = fs:: symlink_metadata ( to) ;
741
- if let Ok ( dest_meta) = dest_meta_res {
742
- if dest_meta. is_symlink ( ) {
743
- // fs::copy fails if destination is a invalid symlink
744
- // so lets just remove all symlinks at destination before copy
745
- fs:: remove_file ( to) ?;
746
- }
747
- }
748
- fs:: copy ( from, to) . map ( |_| ( ) )
749
- }
750
-
751
739
/// Copy a file from one path to another.
752
740
///
753
741
/// # Parameters
@@ -760,6 +748,15 @@ fn copy_file_source_not_dev_null(from: &Path, to: &Path) -> io::Result<()> {
760
748
/// Returns an empty Result or an error in case of failure.
761
749
///
762
750
fn copy_file ( from : & Path , to : & Path ) -> UResult < ( ) > {
751
+ let dest_meta_res = fs:: symlink_metadata ( to) ;
752
+ if let Ok ( dest_meta) = dest_meta_res {
753
+ if dest_meta. is_symlink ( ) {
754
+ // fs::copy fails if destination is a invalid symlink
755
+ // so lets just remove all symlinks at destination before copy
756
+ fs:: remove_file ( to) ?;
757
+ }
758
+ }
759
+
763
760
if from. as_os_str ( ) == "/dev/null" {
764
761
/* workaround a limitation of fs::copy
765
762
* https://github.com/rust-lang/rust/issues/79390
@@ -770,7 +767,7 @@ fn copy_file(from: &Path, to: &Path) -> UResult<()> {
770
767
) ;
771
768
}
772
769
} else {
773
- let result = copy_file_source_not_dev_null ( from, to) ;
770
+ let result = fs :: copy ( from, to) ;
774
771
if let Err ( err) = result {
775
772
return Err (
776
773
InstallError :: InstallFailed ( from. to_path_buf ( ) , to. to_path_buf ( ) , err) . into ( ) ,
0 commit comments