""", uuid,
)
- async def create(self, archive):
+ async def create(self, upload):
+ """
+ Creates a new package from an uploaded file
+ """
+ # Check if the upload has been completed
+ if not upload.is_completed():
+ raise RuntimeError("Cannot import package from incomplete upload")
+
+ # Upload the archive
+ archive = await self.backend.open(upload.path)
+
# Extract package metadata from archive
package = archive.get_package()
raise tornado.web.HTTPError(403, "No permission for using upload %s" % upload)
with self.db.transaction():
- # Try opening the archive
- archive = await self.backend.open(upload.path)
-
- # Extract the package metadata
- package = archive.get_package()
-
# Import the package
- package = await self.backend.packages.create(archive)
+ package = await self.backend.packages.create(upload)
# XXX Fetch the distribution
# XXX Fetch the repository
# Check if the file exists
self.assertTrue(os.path.exists(path))
- # Open the archive
- archive = await self.backend.open(path)
-
- # Check if we received the correct type
- self.assertIsInstance(archive, Archive)
+ # Upload the file
+ upload = await self._create_upload(path)
# Create the package
- package = await self.backend.packages.create(archive)
+ package = await self.backend.packages.create(upload)
# Check if we received the correct type
self.assertIsInstance(package, packages.Package)