From: Michael Tremer Date: Tue, 18 Oct 2022 17:12:57 +0000 (+0000) Subject: jobs: Import packages when the job finishes X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c158f3caf620679bcc72cc3a09f87fe31ec99c87;p=pbs.git jobs: Import packages when the job finishes Signed-off-by: Michael Tremer --- diff --git a/src/buildservice/jobs.py b/src/buildservice/jobs.py index 9029e83b..7c210830 100644 --- a/src/buildservice/jobs.py +++ b/src/buildservice/jobs.py @@ -164,10 +164,27 @@ class Job(base.DataObject): """ Will take a list of uploads and import them as packages """ - for upload in uploads: - pass + # Import all packages + packages = await asyncio.gather( + *(self.backend.packages.create(upload) for upload in uploads), + ) + + # Add them to the database + self.db.executemany(""" + INSERT INTO + jobs_packages( + job_id, + pkg_id + ) + VALUES( + %s, %s + )""", ( + (self.id, package.id) for package in packages + ) + ) - # XXX TODO + # Update the cache + self.packages = packages @property def size(self):