From a87578963ef25095d2bce0ba4247c7dedb0e1a74 Mon Sep 17 00:00:00 2001 From: dorpvom Date: Tue, 3 Jan 2023 13:51:57 +0100 Subject: [PATCH] added early exit if extraction is skipped --- unblob/processing.py | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/unblob/processing.py b/unblob/processing.py index c0cdb6735a..c0167782fc 100644 --- a/unblob/processing.py +++ b/unblob/processing.py @@ -367,21 +367,24 @@ def _extract_chunk(self, file, chunk: ValidChunk): extract_dir = self.carve_dir / (inpath.name + self.config.extract_suffix) carved_path = inpath + if self.config.skip_extraction: + fix_extracted_directory(extract_dir, self.result) + return + extraction_reports = [] - if not self.config.skip_extraction: - try: - chunk.extract(inpath, extract_dir) + try: + chunk.extract(inpath, extract_dir) - if carved_path and not self.config.keep_extracted_chunks: - logger.debug("Removing extracted chunk", path=carved_path) - carved_path.unlink() + if carved_path and not self.config.keep_extracted_chunks: + logger.debug("Removing extracted chunk", path=carved_path) + carved_path.unlink() - except ExtractError as e: - extraction_reports.extend(e.reports) + except ExtractError as e: + extraction_reports.extend(e.reports) - except Exception as exc: - logger.exception("Unknown error happened while extracting chunk") - extraction_reports.append(UnknownError(exception=exc)) + except Exception as exc: + logger.exception("Unknown error happened while extracting chunk") + extraction_reports.append(UnknownError(exception=exc)) self.result.add_report(chunk.as_report(extraction_reports))