Skip to content

Commit

Permalink
Fix source package publish error
Browse files Browse the repository at this point in the history
Handle a source package publish IntegrityError when a source package
belongs to multiple dists.

fixes #1053
  • Loading branch information
daviddavis committed Mar 25, 2024
1 parent 270eb2c commit 6490574
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
2 changes: 2 additions & 0 deletions CHANGES/1053.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fixed a bug where an ``IntegrityError`` was raised during publish when a source package belonged to
two dists.
17 changes: 9 additions & 8 deletions pulp_deb/app/tasks/publishing.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,14 +325,15 @@ def add_package(self, package):
def add_source_package(self, source_package):
artifact_set = source_package.contentartifact_set.all()
for content_artifact in artifact_set:
published_artifact = PublishedArtifact(
relative_path=source_package.derived_path(
os.path.basename(content_artifact.relative_path), self.component
),
publication=self.parent.publication,
content_artifact=content_artifact,
)
published_artifact.save()
with suppress(IntegrityError):
published_artifact = PublishedArtifact(
relative_path=source_package.derived_path(
os.path.basename(content_artifact.relative_path), self.component
),
publication=self.parent.publication,
content_artifact=content_artifact,
)
published_artifact.save()
dsc_file_822_serializer = DscFile822Serializer(source_package, context={"request": None})
dsc_file_822_serializer.to822(self.component, paragraph=True).dump(
self.source_index_file_info[0]
Expand Down

0 comments on commit 6490574

Please sign in to comment.