@@ -35,6 +35,7 @@ use uucore::selinux::{
3535} ;
3636use uucore:: translate;
3737use uucore:: { format_usage, show, show_error, show_if_err} ;
38+ use uucore:: error:: UIoError ;
3839
3940#[ cfg( unix) ]
4041use std:: os:: unix:: fs:: MetadataExt ;
@@ -843,7 +844,8 @@ fn copy_file(from: &Path, to: &Path) -> UResult<()> {
843844 // see if the file exists, and it can't even be checked, this means we
844845 // don't have permission to access the file, so we should return an error.
845846 if let Err ( to_stat) = to. try_exists ( ) {
846- return Err ( InstallError :: CannotStat ( to. to_path_buf ( ) , to_stat. to_string ( ) ) . into ( ) ) ;
847+ let err = UIoError :: from ( to_stat) ;
848+ return Err ( InstallError :: CannotStat ( to. to_path_buf ( ) , err. to_string ( ) ) . into ( ) ) ;
847849 }
848850
849851 if to. is_dir ( ) && !from. is_dir ( ) {
@@ -862,7 +864,8 @@ fn copy_file(from: &Path, to: &Path) -> UResult<()> {
862864 // If we get here, then remove_file failed for some
863865 // reason other than the file not existing. This means
864866 // this should be a fatal error, not a warning.
865- return Err ( InstallError :: FailedToRemove ( to. to_path_buf ( ) , e. to_string ( ) ) . into ( ) ) ;
867+ let err = UIoError :: from ( e) ;
868+ return Err ( InstallError :: FailedToRemove ( to. to_path_buf ( ) , err. to_string ( ) ) . into ( ) ) ;
866869 }
867870 }
868871
0 commit comments