From 6490574b6471f20726c5a37db324fa6084f30f01 Mon Sep 17 00:00:00 2001 From: David Davis Date: Mon, 25 Mar 2024 14:34:10 -0400 Subject: [PATCH] Fix source package publish error Handle a source package publish IntegrityError when a source package belongs to multiple dists. fixes #1053 --- CHANGES/1053.bugfix | 2 ++ pulp_deb/app/tasks/publishing.py | 17 +++++++++-------- 2 files changed, 11 insertions(+), 8 deletions(-) create mode 100644 CHANGES/1053.bugfix diff --git a/CHANGES/1053.bugfix b/CHANGES/1053.bugfix new file mode 100644 index 000000000..ed7d596c7 --- /dev/null +++ b/CHANGES/1053.bugfix @@ -0,0 +1,2 @@ +Fixed a bug where an ``IntegrityError`` was raised during publish when a source package belonged to +two dists. diff --git a/pulp_deb/app/tasks/publishing.py b/pulp_deb/app/tasks/publishing.py index 0befd4d20..908303d97 100644 --- a/pulp_deb/app/tasks/publishing.py +++ b/pulp_deb/app/tasks/publishing.py @@ -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]