]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/controllers/api/video-channel.ts
Fix retrying update on sql serialization conflict
[github/Chocobozzz/PeerTube.git] / server / controllers / api / video-channel.ts
index d7c92952a516de29ea417a2a3e1790c6ae0e7750..5b9fb794ae9bb94a7afba909efc060aa59e34a48 100644 (file)
@@ -273,7 +273,6 @@ async function addVideoChannel (req: express.Request, res: express.Response) {
 
 async function updateVideoChannel (req: express.Request, res: express.Response) {
   const videoChannelInstance = res.locals.videoChannel
-  const videoChannelFieldsSave = videoChannelInstance.toJSON()
   const oldVideoChannelAuditKeys = new VideoChannelAuditView(videoChannelInstance.toFormattedJSON())
   const videoChannelInfoToUpdate = req.body as VideoChannelUpdate
   let doBulkVideoUpdate = false
@@ -309,10 +308,9 @@ async function updateVideoChannel (req: express.Request, res: express.Response)
   } catch (err) {
     logger.debug('Cannot update the video channel.', { 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(videoChannelInstance, videoChannelFieldsSave)
+    // So we need to restore the previous fields
+    resetSequelizeInstance(videoChannelInstance)
 
     throw err
   }