Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use non-streaming mode and default compression level 6 #22

Merged
merged 3 commits into from
Dec 4, 2023
Merged
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
12 changes: 11 additions & 1 deletion securetar/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,19 @@ def __init__(
self._mode: str = mode
self._name: Path = name
self._bufsize: int = bufsize
self._extra_args = {}

# Tarfile options
self._tar: Optional[tarfile.TarFile] = None
self._tar_mode: str = f"{mode}|gz" if gzip else f"{mode}|"
if key:
self._tar_mode = f"{mode}|"
else:
self._tar_mode = f"{mode}:"
if gzip:
self._extra_args["compresslevel"] = 6

if gzip:
self._tar_mode = self._tar_mode + "gz"

# Encryption/Description
self._aes: Optional[Cipher] = None
Expand All @@ -62,6 +71,7 @@ def __enter__(self) -> tarfile.TarFile:
mode=self._tar_mode,
dereference=False,
bufsize=self._bufsize,
**self._extra_args,
)
return self._tar

Expand Down
Loading