X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=src%2Fhub%2Fhandlers.py;h=37fb60e9480690dfe008991b5c8679b3def3195a;hb=2f64fe6858c09905ec2ccf0266d811d7c414d3ab;hp=c51d9ad2c6bd4a4f24a81121d6fa4dc396891237;hpb=9f2cdc4737319029152373e410ad2533227c37ec;p=people%2Fjschlag%2Fpbs.git diff --git a/src/hub/handlers.py b/src/hub/handlers.py index c51d9ad..37fb60e 100644 --- a/src/hub/handlers.py +++ b/src/hub/handlers.py @@ -151,10 +151,11 @@ class UploadsCreateHandler(BaseHandler): filesize = self.get_argument_int("filesize") filehash = self.get_argument("hash") - upload = uploads.Upload.create(self.backend, filename, filesize, - filehash, user=self.user, builder=self.builder) + with self.db.transaction(): + upload = self.backend.uploads.create(filename, filesize, + filehash, user=self.user, builder=self.builder) - self.finish(upload.uuid) + self.finish(upload.uuid) class UploadsSendChunkHandler(BaseHandler): @@ -181,7 +182,8 @@ class UploadsSendChunkHandler(BaseHandler): raise tornado.web.HTTPError(400, "Checksum mismatch") # Append the data to file. - upload.append(data) + with self.db.transaction(): + upload.append(data) class UploadsFinishedHandler(BaseHandler): @@ -207,7 +209,8 @@ class UploadsFinishedHandler(BaseHandler): # In case the download was corrupted or incomplete, we delete it # and tell the client to start over. - upload.remove() + with self.db.transaction(): + upload.remove() self.finish("ERROR: CORRUPTED OR INCOMPLETE FILE") @@ -223,7 +226,8 @@ class UploadsDestroyHandler(BaseHandler): raise tornado.web.HTTPError(403, "Removing an other host's file.") # Remove the upload from the database and trash the data. - upload.remove() + with self.db.transaction(): + upload.remove() # Builds