]> git.ipfire.org Git - pbs.git/commitdiff
hub: Extract the distribution from package
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 18 Oct 2022 18:01:50 +0000 (18:01 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 18 Oct 2022 18:01:50 +0000 (18:01 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/hub/builds.py

index 49cf54b33589f95987dd7b74a832a12f8cd991a4..fe4de4501184b2cf57485971b032a1c993c6a977 100644 (file)
@@ -21,6 +21,8 @@
 
 import tornado.web
 
+from ..errors import NoSuchDistroError
+
 from .handlers import BaseHandler
 
 class CreateHandler(BaseHandler):
@@ -36,9 +38,15 @@ class CreateHandler(BaseHandler):
 
                with self.db.transaction():
                        # Import the package
-                       package = await self.backend.packages.create(upload)
+                       try:
+                               package = await self.backend.packages.create(upload)
+
+                       # If the distribution that is coded into the package could not be found,
+                       # we will send that error to the user
+                       except NoSuchDistroError as e:
+                               # XXX probably send something better than this
+                               raise tornado.web.HTTPError(404, "Could not find distribution: %s" % e)
 
-                       # XXX Fetch the distribution
                        # XXX Fetch the repository
                        repo = self.backend.repos.get_by_id(1)