@@ -290,7 +290,7 @@ pub(crate) fn prepare_session_directory(sess: &Session, crate_name: Symbol) {
290
290
291
291
// Try to remove the session directory we just allocated. We don't
292
292
// 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) {
294
294
sess. dcx ( ) . emit_warn ( errors:: DeletePartial { path : & session_dir, err } ) ;
295
295
}
296
296
@@ -324,7 +324,7 @@ pub fn finalize_session_directory(sess: &Session, svh: Option<Svh>) {
324
324
incr_comp_session_dir. display( )
325
325
) ;
326
326
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) {
328
328
sess. dcx ( ) . emit_warn ( errors:: DeleteFull { path : & incr_comp_session_dir, err } ) ;
329
329
}
330
330
@@ -715,7 +715,7 @@ pub(crate) fn garbage_collect_session_directories(sess: &Session) -> io::Result<
715
715
for directory_name in session_directories {
716
716
if !lock_file_to_session_dir. items ( ) . any ( |( _, dir) | * dir == directory_name) {
717
717
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) {
719
719
sess. dcx ( ) . emit_warn ( errors:: InvalidGcFailed { path : & path, err } ) ;
720
720
}
721
721
}
@@ -821,7 +821,7 @@ pub(crate) fn garbage_collect_session_directories(sess: &Session) -> io::Result<
821
821
all_except_most_recent ( deletion_candidates) . into_items ( ) . all ( |( path, lock) | {
822
822
debug ! ( "garbage_collect_session_directories() - deleting `{}`" , path. display( ) ) ;
823
823
824
- if let Err ( err) = safe_remove_dir_all ( & path) {
824
+ if let Err ( err) = std_fs :: remove_dir_all ( & path) {
825
825
sess. dcx ( ) . emit_warn ( errors:: FinalizedGcFailed { path : & path, err } ) ;
826
826
} else {
827
827
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<
839
839
fn delete_old ( sess : & Session , path : & Path ) {
840
840
debug ! ( "garbage_collect_session_directories() - deleting `{}`" , path. display( ) ) ;
841
841
842
- if let Err ( err) = safe_remove_dir_all ( path) {
842
+ if let Err ( err) = std_fs :: remove_dir_all ( path) {
843
843
sess. dcx ( ) . emit_warn ( errors:: SessionGcFailed { path, err } ) ;
844
844
} else {
845
845
delete_session_dir_lock_file ( sess, & lock_file_path ( path) ) ;
@@ -862,30 +862,8 @@ fn all_except_most_recent(
862
862
}
863
863
}
864
864
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
-
881
865
fn 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) {
889
867
Err ( err) if err. kind ( ) == io:: ErrorKind :: NotFound => Ok ( ( ) ) ,
890
868
result => result,
891
869
}
0 commit comments