Skip to content

Commit f94f8ca

Browse files
committed
Use createrepo_c flags to ensure we don't parse file digests
Parsing file digests changes the API, due to an accident. We've already handled that, but we can avoid it happening in the first place and save some memory while we're at it.
1 parent 0136f85 commit f94f8ca

File tree

6 files changed

+18
-5
lines changed

6 files changed

+18
-5
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Set a flag during RPM parsing to ensure we don't load file digests.

pulp_rpm/app/constants.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from types import SimpleNamespace
2+
import createrepo_c as cr
23

34
# metadata compression types supported
45
COMPRESSION_TYPES = SimpleNamespace(
@@ -51,6 +52,8 @@
5152
(CHECKSUM_TYPES.SHA512, CHECKSUM_TYPES.SHA512),
5253
)
5354

55+
CR_HEADER_FLAGS = cr.HDRR_NOFILEDIGESTS
56+
5457
ALLOWED_CHECKSUM_ERROR_MSG = """Checksum must be one of the allowed checksum types.
5558
You can adjust these with the 'ALLOWED_CONTENT_CHECKSUMS' setting."""
5659

pulp_rpm/app/serializers/package.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from tempfile import NamedTemporaryFile
2222
from pulpcore.plugin.util import get_domain_pk
2323

24+
from pulp_rpm.app.contants import CR_HEADER_FLAGS
2425
from pulp_rpm.app.models import Package
2526
from pulp_rpm.app.shared_utils import format_nvra, read_crpackage_from_artifact
2627

@@ -429,7 +430,9 @@ def validate(self, data):
429430
try:
430431
if uploaded_file:
431432
cr_object = cr.package_from_rpm(
432-
uploaded_file.file.name, changelog_limit=settings.KEEP_CHANGELOG_LIMIT
433+
uploaded_file.file.name,
434+
changelog_limit=settings.KEEP_CHANGELOG_LIMIT,
435+
header_reading_flags=CR_HEADER_FLAGS,
433436
)
434437
new_pkg = Package.createrepo_to_dict(cr_object)
435438
elif upload:
@@ -446,7 +449,9 @@ def validate(self, data):
446449

447450
# Now we have a file, read metadata from it
448451
cr_object = cr.package_from_rpm(
449-
temp_file.name, changelog_limit=settings.KEEP_CHANGELOG_LIMIT
452+
temp_file.name,
453+
changelog_limit=settings.KEEP_CHANGELOG_LIMIT,
454+
header_reading_flags=CR_HEADER_FLAGS,
450455
)
451456
new_pkg = Package.createrepo_to_dict(cr_object)
452457

pulp_rpm/app/shared_utils.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
from django.conf import settings
1111
from django.utils.dateparse import parse_datetime
1212
from importlib_resources import files
13+
1314
from pulpcore.plugin.exceptions import InvalidSignatureError
15+
16+
from pulp_rpm.app.constants import CR_HEADER_FLAGS
1417
from pulp_rpm.app.rpm_version import RpmVersion
1518

1619

@@ -97,7 +100,9 @@ def read_crpackage_from_artifact(artifact, working_dir="."):
97100
shutil.copyfileobj(artifact_file, temp_file)
98101
temp_file.flush()
99102
cr_pkginfo = cr.package_from_rpm(
100-
temp_file.name, changelog_limit=settings.KEEP_CHANGELOG_LIMIT
103+
temp_file.name,
104+
changelog_limit=settings.KEEP_CHANGELOG_LIMIT,
105+
header_reading_flags=CR_HEADER_FLAGS,
101106
)
102107

103108
artifact_file.close()

pulp_rpm/app/tasks/signing.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
from pulp_rpm.app.models.package import Package
2424
from pulp_rpm.app.models.repository import RpmRepository
2525

26-
2726
log = logging.getLogger(__name__)
2827

2928

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ classifiers = [
2626
]
2727
requires-python = ">=3.11"
2828
dependencies = [
29-
"createrepo_c~=1.2.1",
29+
"createrepo_c~=1.2.3",
3030
"django_readonly_field~=1.1.1",
3131
"jsonschema>=4.6,<5.0",
3232
"libcomps>=0.1.23.post1,<0.2",

0 commit comments

Comments
 (0)