]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/controllers/api/videos/update.ts
Fix retrying update on sql serialization conflict
[github/Chocobozzz/PeerTube.git] / server / controllers / api / videos / update.ts
index 260dee2b9f14e6fe594d127294fab02d47bbfba3..e6197c4b1b87dd973a3cb510cfc5f645decd95bd 100644 (file)
@@ -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 {