aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-01-12 09:47:21 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-01-12 09:47:21 +0100
commit7f4e7c36373217b8e92cf227c71999a0ce9a15d9 (patch)
tree7c7f49d8066646a593c1d8a8551610dbed0f68aa /server/controllers/api
parent63d00f5ded0aad25eeb50111da65b6daa46bcb24 (diff)
downloadPeerTube-7f4e7c36373217b8e92cf227c71999a0ce9a15d9.tar.gz
PeerTube-7f4e7c36373217b8e92cf227c71999a0ce9a15d9.tar.zst
PeerTube-7f4e7c36373217b8e92cf227c71999a0ce9a15d9.zip
Server: fix update remote video infohash
Diffstat (limited to 'server/controllers/api')
-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