diff options
author | Chocobozzz <me@florianbigard.com> | 2023-02-14 08:59:27 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2023-02-14 09:03:22 +0100 |
commit | 4565774669bc3c1b11cc726d577946953dbe53c5 (patch) | |
tree | ee0e41e06245861a0de896684caa388f82cc3470 /server/controllers/api/video-channel.ts | |
parent | 4c61660a0ab6224079c67d8282b282772a0772e4 (diff) | |
download | PeerTube-4565774669bc3c1b11cc726d577946953dbe53c5.tar.gz PeerTube-4565774669bc3c1b11cc726d577946953dbe53c5.tar.zst PeerTube-4565774669bc3c1b11cc726d577946953dbe53c5.zip |
Fix retrying update on sql serialization conflict
Diffstat (limited to 'server/controllers/api/video-channel.ts')
-rw-r--r-- | server/controllers/api/video-channel.ts | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/server/controllers/api/video-channel.ts b/server/controllers/api/video-channel.ts index d7c92952a..5b9fb794a 100644 --- a/server/controllers/api/video-channel.ts +++ b/server/controllers/api/video-channel.ts | |||
@@ -273,7 +273,6 @@ async function addVideoChannel (req: express.Request, res: express.Response) { | |||
273 | 273 | ||
274 | async function updateVideoChannel (req: express.Request, res: express.Response) { | 274 | async function updateVideoChannel (req: express.Request, res: express.Response) { |
275 | const videoChannelInstance = res.locals.videoChannel | 275 | const videoChannelInstance = res.locals.videoChannel |
276 | const videoChannelFieldsSave = videoChannelInstance.toJSON() | ||
277 | const oldVideoChannelAuditKeys = new VideoChannelAuditView(videoChannelInstance.toFormattedJSON()) | 276 | const oldVideoChannelAuditKeys = new VideoChannelAuditView(videoChannelInstance.toFormattedJSON()) |
278 | const videoChannelInfoToUpdate = req.body as VideoChannelUpdate | 277 | const videoChannelInfoToUpdate = req.body as VideoChannelUpdate |
279 | let doBulkVideoUpdate = false | 278 | let doBulkVideoUpdate = false |
@@ -309,10 +308,9 @@ async function updateVideoChannel (req: express.Request, res: express.Response) | |||
309 | } catch (err) { | 308 | } catch (err) { |
310 | logger.debug('Cannot update the video channel.', { err }) | 309 | logger.debug('Cannot update the video channel.', { err }) |
311 | 310 | ||
312 | // Force fields we want to update | ||
313 | // If the transaction is retried, sequelize will think the object has not changed | 311 | // If the transaction is retried, sequelize will think the object has not changed |
314 | // So it will skip the SQL request, even if the last one was ROLLBACKed! | 312 | // So we need to restore the previous fields |
315 | resetSequelizeInstance(videoChannelInstance, videoChannelFieldsSave) | 313 | resetSequelizeInstance(videoChannelInstance) |
316 | 314 | ||
317 | throw err | 315 | throw err |
318 | } | 316 | } |