Skip to content

Commit

Permalink
Merge pull request #1166 from daviddavis/dsc-sha256
Browse files Browse the repository at this point in the history
Expose the sha256 for source package dsc files
  • Loading branch information
quba42 authored Oct 10, 2024
2 parents 35dfe06 + b714236 commit 3f1f385
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES/+add-dsc-sha256.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Expose a sha256 column for source packages that contains the digest of the dsc file.
5 changes: 5 additions & 0 deletions pulp_deb/app/models/content/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,11 @@ def __init__(self, *args, **kwargs):
kwargs.pop(kw)
super().__init__(*args, **kwargs)

@property
def sha256(self):
"""Return the sha256 of the dsc file."""
return self.contentartifact_set.get(relative_path=self.relative_path).artifact.sha256

def derived_dsc_filename(self):
"""Print a nice name for the Dsc file."""
return "{}_{}.{}".format(self.source, self.version, self.SUFFIX)
Expand Down
2 changes: 2 additions & 0 deletions pulp_deb/app/serializers/content_serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1143,6 +1143,7 @@ class SourcePackageSerializer(MultipleArtifactContentSerializer):
),
required=False,
)
sha256 = CharField(help_text=_("sha256 digest of the dsc file."), read_only=True)
format = CharField(read_only=True)
source = CharField(read_only=True)
binary = CharField(read_only=True)
Expand Down Expand Up @@ -1242,6 +1243,7 @@ class Meta:
fields = MultipleArtifactContentSerializer.Meta.fields + (
"artifact",
"relative_path",
"sha256",
"format",
"source",
"binary",
Expand Down
2 changes: 1 addition & 1 deletion pulp_deb/app/viewsets/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ class SourcePackageViewSet(SingleArtifactContentUploadViewSet):
"""

endpoint_name = "source_packages"
queryset = models.SourcePackage.objects.prefetch_related("_artifacts")
queryset = models.SourcePackage.objects.prefetch_related("_artifacts", "contentartifact_set")
serializer_class = serializers.SourcePackageSerializer
filterset_class = SourcePackageFilter

Expand Down

0 comments on commit 3f1f385

Please sign in to comment.