]> git.ipfire.org Git - pbs.git/commitdiff
uploads: Commit the database session before sending response
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 3 Feb 2025 10:10:52 +0000 (10:10 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 3 Feb 2025 10:10:52 +0000 (10:10 +0000)
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 <michael.tremer@ipfire.org>
src/web/uploads.py

index 888441fee42265a6a70f39aae30f656804497745..d7d9b1898593718470be903a057db60a05fe149f 100644 (file)
@@ -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()