From: Michael Tremer Date: Mon, 3 Feb 2025 10:10:52 +0000 (+0000) Subject: uploads: Commit the database session before sending response X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a8c7a7c254278cc0886ae1c60ef580527255efd2;p=pbs.git uploads: Commit the database session before sending response The client could reconnect very quickly, before the database has session has been commited which will result on the upload failing. Therefore we make sure that the implicitely opened transaction has been commited before we send the response. Signed-off-by: Michael Tremer --- diff --git a/src/web/uploads.py b/src/web/uploads.py index 888441fe..d7d9b189 100644 --- a/src/web/uploads.py +++ b/src/web/uploads.py @@ -198,6 +198,9 @@ class APIv1DetailHandler(base.APIMixin, base.BaseHandler): except ValueError as e: raise base.APIError(errno.EINVAL, "%s" % e) from e + # Commit the session + await self.db.commit() + # Send no response self.set_status(204) self.finish()