← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:ci-build-upload-job-releases-by-format into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:ci-build-upload-job-releases-by-format into launchpad:master.

Commit message:
Look up releases by format in CIBuildUploadJob

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/425225

As with https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/425220, we need to start looking up existing binary package releases by name and format rather than just by name, since a single CI build may (for example) build the same package name as both a wheel and a Conda package.

This can't be tested yet because existing DB unique constraints prevent creating multiple packages with the same CI build and name but different formats.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:ci-build-upload-job-releases-by-format into launchpad:master.
diff --git a/lib/lp/soyuz/model/archivejob.py b/lib/lp/soyuz/model/archivejob.py
index 6fc15b2..3aca24b 100644
--- a/lib/lp/soyuz/model/archivejob.py
+++ b/lib/lp/soyuz/model/archivejob.py
@@ -363,8 +363,8 @@ class CIBuildUploadJob(ArchiveJobDerived):
         """See `IRunnableJob`."""
         logger = logging.getLogger()
         with tempfile.TemporaryDirectory(prefix="ci-build-copy-job") as tmpdir:
-            releases_by_name = {
-                release.binarypackagename: release
+            releases = {
+                (release.binarypackagename, release.binpackageformat): release
                 for release in self.ci_build.binarypackages}
             allowed_binary_formats = (
                 self.binary_format_by_repository_format.get(
@@ -397,7 +397,7 @@ class CIBuildUploadJob(ArchiveJobDerived):
                     getUtility(IBinaryPackageNameSet).ensure(metadata["name"]))
                 del metadata["name"]
                 filetype = self.filetype_by_format[binpackageformat]
-                bpr = releases_by_name.get(bpn)
+                bpr = releases.get((bpn, binpackageformat))
                 if bpr is None:
                     bpr = self.ci_build.createBinaryPackageRelease(**metadata)
                 for bpf in bpr.files: