Skip to content

Commit 5c7ae9e

Browse files
committed
fix(processing): delete empty _extract directories when an ExtractError is raised.
1 parent 78887ab commit 5c7ae9e

File tree

8 files changed

+6
-1
lines changed
  • tests/integration/executable/elf
    • elf32/__output__
      • sample_32_be.elf_extract/13-5877.elf32_extract
      • sample_32_le.elf_extract/13-15601.elf32_extract
    • elf64/__output__
      • hellomod.sha1.brokensig.ko_extract/0-215704.elf64_extract
      • hellomod.sha1.extra.ko_extract/0-216459.elf64_extract
      • hellomod.sha1.nofooter.ko_extract/0-215704.elf64_extract
      • sample_64_be.elf_extract/13-67741.elf64_extract
      • sample_64_le.elf_extract/13-16709.elf64_extract
  • unblob

8 files changed

+6
-1
lines changed

tests/integration/executable/elf/elf32/__output__/sample_32_be.elf_extract/13-5877.elf32_extract/.gitkeep

Whitespace-only changes.

tests/integration/executable/elf/elf32/__output__/sample_32_le.elf_extract/13-15601.elf32_extract/.gitkeep

Whitespace-only changes.

tests/integration/executable/elf/elf64/__output__/hellomod.sha1.brokensig.ko_extract/0-215704.elf64_extract/.gitkeep

Whitespace-only changes.

tests/integration/executable/elf/elf64/__output__/hellomod.sha1.extra.ko_extract/0-216459.elf64_extract/.gitkeep

Whitespace-only changes.

tests/integration/executable/elf/elf64/__output__/hellomod.sha1.nofooter.ko_extract/0-215704.elf64_extract/.gitkeep

Whitespace-only changes.

tests/integration/executable/elf/elf64/__output__/sample_64_be.elf_extract/13-67741.elf64_extract/.gitkeep

Whitespace-only changes.

tests/integration/executable/elf/elf64/__output__/sample_64_le.elf_extract/13-16709.elf64_extract/.gitkeep

Whitespace-only changes.

unblob/processing.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ def _extract_chunk(self, file, chunk: ValidChunk):
389389

390390
except ExtractError as e:
391391
extraction_reports.extend(e.reports)
392-
392+
delete_empty_extract_dir(extract_dir)
393393
except Exception as exc:
394394
logger.exception("Unknown error happened while extracting chunk")
395395
extraction_reports.append(UnknownError(exception=exc))
@@ -409,6 +409,11 @@ def _extract_chunk(self, file, chunk: ValidChunk):
409409
)
410410

411411

412+
def delete_empty_extract_dir(extract_dir: Path):
413+
if extract_dir.exists() and not any(extract_dir.iterdir()):
414+
extract_dir.rmdir()
415+
416+
412417
def remove_inner_chunks(chunks: List[ValidChunk]) -> List[ValidChunk]:
413418
"""Remove all chunks from the list which are within another bigger chunks."""
414419
if not chunks:

0 commit comments

Comments
 (0)