aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers')
-rw-r--r--server/controllers/api/videos.js14
1 files changed, 12 insertions, 2 deletions
diff --git a/server/controllers/api/videos.js b/server/controllers/api/videos.js
index 55d671f5b..2c4af520e 100644
--- a/server/controllers/api/videos.js
+++ b/server/controllers/api/videos.js
@@ -259,6 +259,7 @@ function updateVideoRetryWrapper (req, res, next) {
259 259
260function updateVideo (req, res, finalCallback) { 260function updateVideo (req, res, finalCallback) {
261 const videoInstance = res.locals.video 261 const videoInstance = res.locals.video
262 const videoFieldsSave = videoInstance.toJSON()
262 const videoInfosToUpdate = req.body 263 const videoInfosToUpdate = req.body
263 264
264 waterfall([ 265 waterfall([
@@ -280,12 +281,13 @@ function updateVideo (req, res, finalCallback) {
280 }, 281 },
281 282
282 function updateVideoIntoDB (t, tagInstances, callback) { 283 function updateVideoIntoDB (t, tagInstances, callback) {
283 const options = { transaction: t } 284 const options = {
285 transaction: t
286 }
284 287
285 if (videoInfosToUpdate.name) videoInstance.set('name', videoInfosToUpdate.name) 288 if (videoInfosToUpdate.name) videoInstance.set('name', videoInfosToUpdate.name)
286 if (videoInfosToUpdate.description) videoInstance.set('description', videoInfosToUpdate.description) 289 if (videoInfosToUpdate.description) videoInstance.set('description', videoInfosToUpdate.description)
287 290
288 // Add tags association
289 videoInstance.save(options).asCallback(function (err) { 291 videoInstance.save(options).asCallback(function (err) {
290 return callback(err, t, tagInstances) 292 return callback(err, t, tagInstances)
291 }) 293 })
@@ -321,6 +323,14 @@ function updateVideo (req, res, finalCallback) {
321 // Abort transaction? 323 // Abort transaction?
322 if (t) t.rollback() 324 if (t) t.rollback()
323 325
326 // Force fields we want to update
327 // If the transaction is retried, sequelize will think the object has not changed
328 // So it will skip the SQL request, even if the last one was ROLLBACKed!
329 Object.keys(videoFieldsSave).forEach(function (key) {
330 const value = videoFieldsSave[key]
331 videoInstance.set(key, value)
332 })
333
324 return finalCallback(err) 334 return finalCallback(err)
325 } 335 }
326 336