@@ -290,7 +290,7 @@ pub(crate) fn prepare_session_directory(sess: &Session, crate_name: Symbol) {
290290
291291 // Try to remove the session directory we just allocated. We don't
292292 // know if there's any garbage in it from the failed copy action.
293- if let Err ( err) = safe_remove_dir_all ( & session_dir) {
293+ if let Err ( err) = std_fs :: remove_dir_all ( & session_dir) {
294294 sess. dcx ( ) . emit_warn ( errors:: DeletePartial { path : & session_dir, err } ) ;
295295 }
296296
@@ -324,7 +324,7 @@ pub fn finalize_session_directory(sess: &Session, svh: Option<Svh>) {
324324 incr_comp_session_dir. display( )
325325 ) ;
326326
327- if let Err ( err) = safe_remove_dir_all ( & * incr_comp_session_dir) {
327+ if let Err ( err) = std_fs :: remove_dir_all ( & * incr_comp_session_dir) {
328328 sess. dcx ( ) . emit_warn ( errors:: DeleteFull { path : & incr_comp_session_dir, err } ) ;
329329 }
330330
@@ -715,7 +715,7 @@ pub(crate) fn garbage_collect_session_directories(sess: &Session) -> io::Result<
715715 for directory_name in session_directories {
716716 if !lock_file_to_session_dir. items ( ) . any ( |( _, dir) | * dir == directory_name) {
717717 let path = crate_directory. join ( directory_name) ;
718- if let Err ( err) = safe_remove_dir_all ( & path) {
718+ if let Err ( err) = std_fs :: remove_dir_all ( & path) {
719719 sess. dcx ( ) . emit_warn ( errors:: InvalidGcFailed { path : & path, err } ) ;
720720 }
721721 }
@@ -821,7 +821,7 @@ pub(crate) fn garbage_collect_session_directories(sess: &Session) -> io::Result<
821821 all_except_most_recent ( deletion_candidates) . into_items ( ) . all ( |( path, lock) | {
822822 debug ! ( "garbage_collect_session_directories() - deleting `{}`" , path. display( ) ) ;
823823
824- if let Err ( err) = safe_remove_dir_all ( & path) {
824+ if let Err ( err) = std_fs :: remove_dir_all ( & path) {
825825 sess. dcx ( ) . emit_warn ( errors:: FinalizedGcFailed { path : & path, err } ) ;
826826 } else {
827827 delete_session_dir_lock_file ( sess, & lock_file_path ( & path) ) ;
@@ -839,7 +839,7 @@ pub(crate) fn garbage_collect_session_directories(sess: &Session) -> io::Result<
839839fn delete_old ( sess : & Session , path : & Path ) {
840840 debug ! ( "garbage_collect_session_directories() - deleting `{}`" , path. display( ) ) ;
841841
842- if let Err ( err) = safe_remove_dir_all ( path) {
842+ if let Err ( err) = std_fs :: remove_dir_all ( path) {
843843 sess. dcx ( ) . emit_warn ( errors:: SessionGcFailed { path, err } ) ;
844844 } else {
845845 delete_session_dir_lock_file ( sess, & lock_file_path ( path) ) ;
@@ -862,30 +862,8 @@ fn all_except_most_recent(
862862 }
863863}
864864
865- /// Since paths of artifacts within session directories can get quite long, we
866- /// need to support deleting files with very long paths. The regular
867- /// WinApi functions only support paths up to 260 characters, however. In order
868- /// to circumvent this limitation, we canonicalize the path of the directory
869- /// before passing it to std::fs::remove_dir_all(). This will convert the path
870- /// into the '\\?\' format, which supports much longer paths.
871- fn safe_remove_dir_all ( p : & Path ) -> io:: Result < ( ) > {
872- let canonicalized = match try_canonicalize ( p) {
873- Ok ( canonicalized) => canonicalized,
874- Err ( err) if err. kind ( ) == io:: ErrorKind :: NotFound => return Ok ( ( ) ) ,
875- Err ( err) => return Err ( err) ,
876- } ;
877-
878- std_fs:: remove_dir_all ( canonicalized)
879- }
880-
881865fn safe_remove_file ( p : & Path ) -> io:: Result < ( ) > {
882- let canonicalized = match try_canonicalize ( p) {
883- Ok ( canonicalized) => canonicalized,
884- Err ( err) if err. kind ( ) == io:: ErrorKind :: NotFound => return Ok ( ( ) ) ,
885- Err ( err) => return Err ( err) ,
886- } ;
887-
888- match std_fs:: remove_file ( canonicalized) {
866+ match std_fs:: remove_file ( p) {
889867 Err ( err) if err. kind ( ) == io:: ErrorKind :: NotFound => Ok ( ( ) ) ,
890868 result => result,
891869 }
0 commit comments