fix: Make tar decompression only consider regular files

The `tar` decompression function was failing for some users, with error
message:

```
'NoneType' object does not support the context manager protocol
```

As explained in the official documentation [1], the `extractfile` method
returns `None` if the member is not a regular file or a link. This
change skips any member that is not a regular file.

[1] https://docs.python.org/3/library/tarfile.html#tarfile.TarFile.extractfile
This commit is contained in:
Michael Manganiello
2024-10-26 01:07:27 -03:00
parent 373757e3ad
commit 8fd680ab84

View File

@@ -93,6 +93,10 @@ def read_tar_file(file_path: Path, mode: str = "r") -> Iterator[bytes]:
try:
with tarfile.open(file_path, mode) as f:
for member in f.getmembers():
# Ignore directories and any other non-regular files
if not member.isfile():
continue
# Ignore metadata files created by macOS
if member.name.startswith("._"):
continue