Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
"""
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):