Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose the sha256 for source package dsc files #1166

Merged
merged 1 commit into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is important, but I tried to look up where contentartifact_set is defined, and could not find it. Am I just being blind?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a method that django defines when you have a many-to-one relationship.


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 @@ -1146,6 +1146,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 @@ -1245,6 +1246,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