File tree Expand file tree Collapse file tree 3 files changed +12
-4
lines changed Expand file tree Collapse file tree 3 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -479,8 +479,16 @@ impl TmcCore {
479479 }
480480
481481 pub fn reset ( & self , exercise_id : usize , exercise_path : & Path ) -> Result < ( ) > {
482- fs:: remove_dir_all ( exercise_path)
483- . map_err ( |e| CoreError :: DirRemove ( exercise_path. to_path_buf ( ) , e) ) ?;
482+ // windows sometimes fails due to files being in use, retry a few times
483+ // todo: handle properly
484+ let mut tries = 0 ;
485+ while let Err ( err) = fs:: remove_dir_all ( exercise_path) {
486+ tries += 1 ;
487+ if tries > 8 {
488+ return Err ( CoreError :: DirRemove ( exercise_path. to_path_buf ( ) , err) ) ;
489+ }
490+ thread:: sleep ( Duration :: from_secs ( 1 ) ) ;
491+ }
484492 self . download_or_update_exercises ( vec ! [ ( exercise_id, exercise_path) ] )
485493 }
486494
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ pub use zip::result::ZipError;
1212use zip:: { write:: FileOptions , ZipArchive , ZipWriter } ;
1313
1414/// Zips the given directory, only including student files according to the given policy.
15- pub fn zip ( policy : Box < dyn StudentFilePolicy > , root_directory : & Path ) -> Result < Vec < u8 > > {
15+ pub fn zip < P : StudentFilePolicy > ( policy : P , root_directory : & Path ) -> Result < Vec < u8 > > {
1616 let mut writer = ZipWriter :: new ( Cursor :: new ( vec ! [ ] ) ) ;
1717 let tmc_project_yml = policy. get_tmc_project_yml ( ) ?;
1818
Original file line number Diff line number Diff line change @@ -149,7 +149,7 @@ pub trait LanguagePlugin {
149149 /// Compress a given project so that it can be sent to the TestMyCode server.
150150 fn compress_project ( & self , path : & Path ) -> Result < Vec < u8 > > {
151151 let policy = Self :: get_student_file_policy ( path) ;
152- Ok ( tmc_zip:: zip ( Box :: new ( policy) , path) ?)
152+ Ok ( tmc_zip:: zip ( policy, path) ?)
153153 }
154154
155155 fn get_student_file_policy ( project_path : & Path ) -> Self :: StudentFilePolicy ;
You can’t perform that action at this time.
0 commit comments