From dea32aacde362a5fbd62a88cd32487768b788468 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 11 Jan 2017 16:22:50 +0100 Subject: Server: always check commit result --- server/controllers/api/remote/videos.js | 16 +++++++++++----- server/controllers/api/videos.js | 23 +++++++++++++++-------- 2 files changed, 26 insertions(+), 13 deletions(-) (limited to 'server/controllers') diff --git a/server/controllers/api/remote/videos.js b/server/controllers/api/remote/videos.js index 6d768eae8..17bdce019 100644 --- a/server/controllers/api/remote/videos.js +++ b/server/controllers/api/remote/videos.js @@ -171,9 +171,12 @@ function addRemoteVideo (videoToCreateData, fromPod, finalCallback) { } // Commit transaction - t.commit() + t.commit().asCallback(function (err) { + if (err) return finalCallback(err) - return finalCallback() + logger.info('Remote video %s inserted.', videoToCreateData.videoToCreateData.name) + return finalCallback(null) + }) }) } @@ -254,10 +257,13 @@ function updateRemoteVideo (videoAttributesToUpdate, fromPod, finalCallback) { return finalCallback(err) } - // Commit transaction - t.commit() + // Commit transaction + t.commit().asCallback(function (err) { + if (err) return finalCallback(err) - return finalCallback() + logger.info('Remote video %s updated', videoAttributesToUpdate.name) + return finalCallback(null) + }) }) } diff --git a/server/controllers/api/videos.js b/server/controllers/api/videos.js index 6573b1210..df068f961 100644 --- a/server/controllers/api/videos.js +++ b/server/controllers/api/videos.js @@ -231,11 +231,12 @@ function addVideo (req, res, videoFile, callback) { } // Commit transaction - t.commit() + t.commit().asCallback(function (err) { + if (err) return callback(err) - logger.info('Video with name %s created.', videoInfos.name) - - return callback(null) + logger.info('Video with name %s created.', videoInfos.name) + return callback(null) + }) }) } @@ -324,9 +325,12 @@ function updateVideo (req, res, finalCallback) { } // Commit transaction - t.commit() + t.commit().asCallback(function (err) { + if (err) return finalCallback(err) - return finalCallback(null) + logger.info('Video with name %s updated.', videoInfosToUpdate.name) + return finalCallback(null) + }) }) } @@ -442,9 +446,12 @@ function reportVideoAbuse (req, res, finalCallback) { } // Commit transaction - t.commit() + t.commit().asCallback(function (err) { + if (err) return finalCallback(err) - return finalCallback(null) + logger.info('Abuse report for video %s created.', videoInstance.name) + return finalCallback(null) + }) }) } -- cgit v1.2.3