diff --git a/CHANGES/3225.misc b/CHANGES/3225.misc new file mode 100644 index 000000000..e1a600d91 --- /dev/null +++ b/CHANGES/3225.misc @@ -0,0 +1 @@ +Load one Artifact checksum type taken package_checksum_type during publish metadata generation. diff --git a/pulp_rpm/app/tasks/publishing.py b/pulp_rpm/app/tasks/publishing.py index d0b25a441..34c1c00d2 100644 --- a/pulp_rpm/app/tasks/publishing.py +++ b/pulp_rpm/app/tasks/publishing.py @@ -479,16 +479,16 @@ 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) @@ -496,8 +496,7 @@ def generate_repo_metadata( 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: