]> git.ipfire.org Git - pbs.git/commitdiff
jobs: Import packages when the job finishes
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 18 Oct 2022 17:12:57 +0000 (17:12 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 18 Oct 2022 17:12:57 +0000 (17:12 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/buildservice/jobs.py

index 9029e83b3bf00501a1dfdf514e82c0ef829011ea..7c210830f08f2c6bc8b4d1f7fbf409f821dbce9c 100644 (file)
@@ -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):