1313from unblob .handlers import BUILTIN_DIR_HANDLERS , BUILTIN_HANDLERS , Handlers
1414
1515from .extractor import carve_unknown_chunk , carve_valid_chunk , fix_extracted_directory
16- from .file_utils import iterate_file
16+ from .file_utils import InvalidInputFormat , iterate_file
1717from .finder import search_chunks
1818from .iter_utils import pairwise
1919from .logging import noformat
2020from .models import (
2121 Chunk ,
22+ DirectoryHandler ,
2223 DirectoryHandlers ,
2324 ExtractError ,
2425 File ,
3132)
3233from .pool import make_pool
3334from .report import (
35+ CalculateMultiFileExceptionReport ,
3436 EntropyReport ,
3537 ExtractDirectoryExistsReport ,
3638 FileMagicReport ,
@@ -324,7 +326,7 @@ def _process_directory(self) -> Tuple[Set[Path], Set[Path]]:
324326 dir_handler = dir_handler_class ()
325327
326328 for path in dir_handler .PATTERN .get_files (self .dir_task .path ):
327- multi_file = dir_handler . calculate_multifile ( path )
329+ multi_file = self . _calculate_multifile ( dir_handler , path , self . result )
328330
329331 if multi_file is None :
330332 continue
@@ -349,6 +351,32 @@ def _process_directory(self) -> Tuple[Set[Path], Set[Path]]:
349351 processed_paths .update (multi_file .paths )
350352 return processed_paths , extract_dirs
351353
354+ @staticmethod
355+ def _calculate_multifile (
356+ dir_handler : DirectoryHandler , path : Path , task_result : TaskResult
357+ ) -> Optional [MultiFile ]:
358+ try :
359+ return dir_handler .calculate_multifile (path )
360+ except InvalidInputFormat as exc :
361+ logger .debug (
362+ "Invalid MultiFile format" ,
363+ exc_info = exc ,
364+ handler = dir_handler .NAME ,
365+ path = path ,
366+ _verbosity = 2 ,
367+ )
368+ except Exception as exc :
369+ error_report = CalculateMultiFileExceptionReport (
370+ handler = dir_handler .NAME ,
371+ exception = exc ,
372+ path = path ,
373+ )
374+ task_result .add_report (error_report )
375+ logger .warning (
376+ "Unhandled Exception during multi file calculation" ,
377+ ** error_report .asdict (),
378+ )
379+
352380 def _check_conflicting_files (
353381 self , multi_file : MultiFile , processed_paths : Set [Path ]
354382 ):
0 commit comments