Skip to content

Commit 309ab24

Browse files
committed
Ensure that non-chunked exports also use compressionlevel=1
closes pulp#4411
1 parent ab2d6f9 commit 309ab24

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

CHANGES/4411.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Ensure non-chunked exports also use gzip compressionlevel=1

pulpcore/app/tasks/export.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import logging
44
import os
55
import os.path
6+
import sys
67
import subprocess
78
import tarfile
89

@@ -414,8 +415,15 @@ def pulp_export(exporter_pk, params):
414415
stdin=subprocess.PIPE,
415416
) as split_process:
416417
try:
417-
with tarfile.open(tarfile_fp, "w|gz", fileobj=split_process.stdin) as tar:
418-
_do_export(pulp_exporter, tar, the_export)
418+
# on Python < 3.12 we have a monkeypatch which enables compression levels
419+
if sys.version_info.major == 3 and sys.version_info.minor < 12:
420+
with tarfile.open(tarfile_fp, "w|gz", fileobj=split_process.stdin) as tar:
421+
_do_export(pulp_exporter, tar, the_export)
422+
else:
423+
with tarfile.open(
424+
tarfile_fp, "w|gz", fileobj=split_process.stdin, compresslevel=1
425+
) as tar:
426+
_do_export(pulp_exporter, tar, the_export)
419427
except Exception:
420428
# no matter what went wrong, we can't trust the files we (may have) created.
421429
# Delete the ones we can find and pass the problem up.
@@ -433,7 +441,7 @@ def pulp_export(exporter_pk, params):
433441
else:
434442
# write into the file
435443
try:
436-
with tarfile.open(tarfile_fp, "w:gz") as tar:
444+
with tarfile.open(tarfile_fp, "w:gz", compresslevel=1) as tar:
437445
_do_export(pulp_exporter, tar, the_export)
438446
except Exception:
439447
# no matter what went wrong, we can't trust the file we created.

0 commit comments

Comments
 (0)