]> git.ipfire.org Git - pbs.git/commitdiff
uploads: Fix deletion
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 22 Jan 2025 13:56:29 +0000 (13:56 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 22 Jan 2025 13:56:29 +0000 (13:56 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/web/uploads.py

index 06abd9328d44d8a9d3013bc21c3f0c335e7983bb..6c36b23e8641e2cb71360a5d8eace00c5ea40f15 100644 (file)
@@ -156,18 +156,21 @@ class APIv1DetailHandler(base.APIMixin, base.BaseHandler):
                """
                        Deletes an upload with a certain UUID
                """
+               # Fetch the current user
+               current_user = await self.get_current_user()
+
                # Fetch the upload
-               upload = self.backend.uploads.get_by_uuid(uuid)
+               upload = await self.backend.uploads.get_by_uuid(uuid)
                if not upload:
                        raise tornado.web.HTTPError(404, "Could not find upload %s" % uuid)
 
                # Check for permissions
-               if not upload.has_perm(self.current_user):
+               if not upload.has_perm(current_user):
                        raise tornado.web.HTTPError(403, "%s has no permission to delete %s" \
-                               % (self.current_user, upload))
+                               % (current_user, upload))
 
                # Delete the upload
-               with self.db.transaction():
+               async with await self.db.transaction():
                        await upload.delete()
 
                # Send a positive response