Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Git LFS file not shown
Git LFS file not shown
8 changes: 6 additions & 2 deletions unblob/handlers/archive/sevenzip.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ class MultiVolumeSevenZipHandler(DirectoryHandler):
PATTERN = Glob("*.7z.001")

def calculate_multifile(self, file: Path) -> Optional[MultiFile]:
paths = sorted(
[p for p in file.parent.glob(f"{file.stem}.*") if p.resolve().exists()]
)
if not paths:
return None

with file.open("rb") as f:
header_data = f.read(HEADER_SIZE)

Expand All @@ -117,8 +123,6 @@ def calculate_multifile(self, file: Path) -> Optional[MultiFile]:
size = calculate_sevenzip_size(header)
logger.debug("Sevenzip header", header=header, size=size, _verbosity=3)

paths = sorted(file.parent.glob(f"{file.stem}.*"))

files_size = sum(path.stat().st_size for path in paths)
logger.debug(
"Multi-volume files", paths=paths, files_size=files_size, _verbosity=2
Expand Down
6 changes: 4 additions & 2 deletions unblob/handlers/compression/gzip.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,14 @@ def is_valid_gzip(self, path: Path) -> bool:
return True

def calculate_multifile(self, file: Path) -> Optional[MultiFile]:
paths = sorted(file.parent.glob(f"{file.stem}.*"))
paths = sorted(
[p for p in file.parent.glob(f"{file.stem}.*") if p.resolve().exists()]
)

# we 'discard' paths that are not the first in the ordered list,
# otherwise we will end up with colliding reports, one for every
# path in the list.
if file != paths[0]:
if not paths or file != paths[0]:
return None

if self.is_valid_gzip(file):
Expand Down