From: Michael Tremer Date: Wed, 22 Jan 2025 13:56:29 +0000 (+0000) Subject: uploads: Fix deletion X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5d15ed69e62294988e22b033a56dc16931de08e1;p=pbs.git uploads: Fix deletion Signed-off-by: Michael Tremer --- diff --git a/src/web/uploads.py b/src/web/uploads.py index 06abd932..6c36b23e 100644 --- a/src/web/uploads.py +++ b/src/web/uploads.py @@ -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