@@ -34,6 +34,7 @@ use uucore::selinux::{
3434} ;
3535use uucore:: translate;
3636use uucore:: { format_usage, show, show_error, show_if_err} ;
37+ use uucore:: error:: UIoError ;
3738
3839#[ cfg( unix) ]
3940use std:: os:: unix:: fs:: { FileTypeExt , MetadataExt } ;
@@ -854,7 +855,8 @@ fn copy_file(from: &Path, to: &Path) -> UResult<()> {
854855 // see if the file exists, and it can't even be checked, this means we
855856 // don't have permission to access the file, so we should return an error.
856857 if let Err ( to_stat) = to. try_exists ( ) {
857- return Err ( InstallError :: CannotStat ( to. to_path_buf ( ) , to_stat. to_string ( ) ) . into ( ) ) ;
858+ let err = UIoError :: from ( to_stat) ;
859+ return Err ( InstallError :: CannotStat ( to. to_path_buf ( ) , err. to_string ( ) ) . into ( ) ) ;
858860 }
859861
860862 if to. is_dir ( ) && !from. is_dir ( ) {
@@ -871,7 +873,8 @@ fn copy_file(from: &Path, to: &Path) -> UResult<()> {
871873 // If we get here, then remove_file failed for some
872874 // reason other than the file not existing. This means
873875 // this should be a fatal error, not a warning.
874- return Err ( InstallError :: FailedToRemove ( to. to_path_buf ( ) , e. to_string ( ) ) . into ( ) ) ;
876+ let err = UIoError :: from ( e) ;
877+ return Err ( InstallError :: FailedToRemove ( to. to_path_buf ( ) , err. to_string ( ) ) . into ( ) ) ;
875878 }
876879 }
877880
0 commit comments