@@ -824,11 +824,17 @@ pub fn extract_project(
824824 let mut archive = Archive :: new ( compressed_project, compression) ?;
825825 plugin. extract_project ( & mut archive, target_location, clean) ?;
826826 } else {
827- log:: debug!(
828- "no matching language plugin found for {}, overwriting" ,
829- target_location. display( )
830- ) ;
831- extract_project_overwrite ( compressed_project, target_location, compression) ?;
827+ let mut archive = Archive :: new ( compressed_project, compression) ?;
828+ if let Ok ( plugin) = PluginType :: from_archive ( & mut archive) {
829+ plugin. extract_project ( & mut archive, target_location, clean) ?;
830+ } else {
831+ log:: debug!(
832+ "no matching language plugin found for {}, extracting naively" ,
833+ target_location. display( )
834+ ) ;
835+ let compressed_project = archive. into_inner ( ) ;
836+ extract_project_overwrite ( compressed_project, target_location, compression) ?;
837+ }
832838 }
833839 Ok ( ( ) )
834840}
@@ -919,11 +925,17 @@ pub fn extract_student_files(
919925 if let Ok ( plugin) = PluginType :: from_exercise ( target_location) {
920926 plugin. extract_student_files ( compressed_project, compression, target_location) ?;
921927 } else {
922- log:: debug!(
923- "no matching language plugin found for {}, overwriting" ,
924- target_location. display( )
925- ) ;
926- extract_project_overwrite ( compressed_project, target_location, Compression :: Zip ) ?;
928+ let mut archive = Archive :: new ( compressed_project, compression) ?;
929+ if let Ok ( plugin) = PluginType :: from_archive ( & mut archive) {
930+ let compressed_project = archive. into_inner ( ) ;
931+ plugin. extract_student_files ( compressed_project, compression, target_location) ?;
932+ } else {
933+ log:: debug!(
934+ "no matching language plugin found for {}, extracting naively" ,
935+ target_location. display( )
936+ ) ;
937+ archive. extract ( target_location) ?;
938+ }
927939 }
928940 Ok ( ( ) )
929941}
0 commit comments