Skip to content

Commit

Permalink
added early exit if extraction is skipped
Browse files Browse the repository at this point in the history
  • Loading branch information
dorpvom committed Jan 3, 2023
1 parent f5a9490 commit a875789
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions unblob/processing.py
Expand Up @@ -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))

Expand Down

0 comments on commit a875789

Please sign in to comment.