@@ -765,7 +765,6 @@ pub fn garbage_collect_session_directories(sess: &Session) -> io::Result<()> {
765
765
766
766
// Now garbage collect the valid session directories.
767
767
let mut deletion_candidates = vec ! [ ] ;
768
- let mut definitely_delete = vec ! [ ] ;
769
768
770
769
for ( lock_file_name, directory_name) in & lock_file_to_session_dir {
771
770
debug ! ( "garbage_collect_session_directories() - inspecting: {}" , directory_name) ;
@@ -842,8 +841,11 @@ pub fn garbage_collect_session_directories(sess: &Session) -> io::Result<()> {
842
841
successfully acquired lock"
843
842
) ;
844
843
845
- // Note that we are holding on to the lock
846
- definitely_delete. push ( ( crate_directory. join ( directory_name) , Some ( lock) ) ) ;
844
+ delete_old ( sess, & crate_directory. join ( directory_name) ) ;
845
+
846
+ // Let's make it explicit that the file lock is released at this point,
847
+ // or rather, that we held on to it until here
848
+ mem:: drop ( lock) ;
847
849
}
848
850
Err ( _) => {
849
851
debug ! (
@@ -880,26 +882,21 @@ pub fn garbage_collect_session_directories(sess: &Session) -> io::Result<()> {
880
882
mem:: drop ( lock) ;
881
883
}
882
884
883
- for ( path , lock ) in definitely_delete {
884
- debug ! ( "garbage_collect_session_directories() - deleting `{}`" , path . display ( ) ) ;
885
+ Ok ( ( ) )
886
+ }
885
887
886
- if let Err ( err) = safe_remove_dir_all ( & path) {
887
- sess. warn ( & format ! (
888
- "Failed to garbage collect incremental \
889
- compilation session directory `{}`: {}",
890
- path. display( ) ,
891
- err
892
- ) ) ;
893
- } else {
894
- delete_session_dir_lock_file ( sess, & lock_file_path ( & path) ) ;
895
- }
888
+ fn delete_old ( sess : & Session , path : & Path ) {
889
+ debug ! ( "garbage_collect_session_directories() - deleting `{}`" , path. display( ) ) ;
896
890
897
- // Let's make it explicit that the file lock is released at this point,
898
- // or rather, that we held on to it until here
899
- mem:: drop ( lock) ;
891
+ if let Err ( err) = safe_remove_dir_all ( & path) {
892
+ sess. warn ( & format ! (
893
+ "Failed to garbage collect incremental compilation session directory `{}`: {}" ,
894
+ path. display( ) ,
895
+ err
896
+ ) ) ;
897
+ } else {
898
+ delete_session_dir_lock_file ( sess, & lock_file_path ( & path) ) ;
900
899
}
901
-
902
- Ok ( ( ) )
903
900
}
904
901
905
902
fn all_except_most_recent (
0 commit comments