Skip to content

Commit

Permalink
Load just one checksum from Artifact.
Browse files Browse the repository at this point in the history
closes #3225

* instead of loading all Artifact checksums load just one based on the
  value from package_checksum_type

(cherry picked from commit 5a603b0)
  • Loading branch information
ipanova authored and dralley committed Aug 16, 2023
1 parent 134fd84 commit a7a819c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGES/3225.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Load one Artifact checksum type taken package_checksum_type during publish metadata generation.
15 changes: 7 additions & 8 deletions pulp_rpm/app/tasks/publishing.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,25 +479,24 @@ def generate_repo_metadata(
# work with select_related() and performs poorly with prefetch_related(). This is fine
# because we know that Packages should only ever have one artifact per content.
fields = [
"artifact__sha256",
"artifact__sha1",
"artifact__sha512",
"artifact__md5",
"artifact__sha224",
"artifact__sha384",
"content_id",
"content__rpm_package__checksum_type",
"content__rpm_package__pkgId",
]
artifact_checksum = None
if package_checksum_type:
package_checksum_type = package_checksum_type.lower()
artifact_checksum = f"artifact__{package_checksum_type}"
fields.append(artifact_checksum)

contentartifact_qs = ContentArtifact.objects.filter(
content__in=content, content__pulp_type=Package.get_pulp_type()
).values(*fields)

pkg_to_hash = {}
for ca in contentartifact_qs.iterator():
if package_checksum_type:
package_checksum_type = package_checksum_type.lower()
pkgid = ca.get(f"artifact__{package_checksum_type}", None)
pkgid = ca.get(artifact_checksum, None)

if not package_checksum_type or not pkgid:
if ca["content__rpm_package__checksum_type"] not in settings.ALLOWED_CONTENT_CHECKSUMS:
Expand Down

0 comments on commit a7a819c

Please sign in to comment.