From 4565774669bc3c1b11cc726d577946953dbe53c5 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 14 Feb 2023 08:59:27 +0100 Subject: Fix retrying update on sql serialization conflict --- server/controllers/api/videos/update.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'server/controllers/api/videos/update.ts') diff --git a/server/controllers/api/videos/update.ts b/server/controllers/api/videos/update.ts index 260dee2b9..e6197c4b1 100644 --- a/server/controllers/api/videos/update.ts +++ b/server/controllers/api/videos/update.ts @@ -45,7 +45,6 @@ export { async function updateVideo (req: express.Request, res: express.Response) { const videoFromReq = res.locals.videoAll - const videoFieldsSave = videoFromReq.toJSON() const oldVideoAuditView = new VideoAuditView(videoFromReq.toFormattedDetailsJSON()) const videoInfoToUpdate: VideoUpdate = req.body @@ -151,10 +150,9 @@ async function updateVideo (req: express.Request, res: express.Response) { isNewVideo }) } catch (err) { - // Force fields we want to update // If the transaction is retried, sequelize will think the object has not changed - // So it will skip the SQL request, even if the last one was ROLLBACKed! - resetSequelizeInstance(videoFromReq, videoFieldsSave) + // So we need to restore the previous fields + resetSequelizeInstance(videoFromReq) throw err } finally { -- cgit v1.2.3