aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/remote/videos.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/api/remote/videos.js')
-rw-r--r--server/controllers/api/remote/videos.js18
1 files changed, 5 insertions, 13 deletions
diff --git a/server/controllers/api/remote/videos.js b/server/controllers/api/remote/videos.js
index 9d007246f..33b521c5f 100644
--- a/server/controllers/api/remote/videos.js
+++ b/server/controllers/api/remote/videos.js
@@ -10,7 +10,7 @@ const secureMiddleware = middlewares.secure
10const videosValidators = middlewares.validators.remote.videos 10const videosValidators = middlewares.validators.remote.videos
11const signatureValidators = middlewares.validators.remote.signature 11const signatureValidators = middlewares.validators.remote.signature
12const logger = require('../../../helpers/logger') 12const logger = require('../../../helpers/logger')
13const utils = require('../../../helpers/utils') 13const databaseUtils = require('../../../helpers/database-utils')
14 14
15const router = express.Router() 15const router = express.Router()
16 16
@@ -71,7 +71,7 @@ function addRemoteVideoRetryWrapper (videoToCreateData, fromPod, finalCallback)
71 errorMessage: 'Cannot insert the remote video with many retries.' 71 errorMessage: 'Cannot insert the remote video with many retries.'
72 } 72 }
73 73
74 utils.retryWrapper(addRemoteVideo, options, finalCallback) 74 databaseUtils.retryTransactionWrapper(addRemoteVideo, options, finalCallback)
75} 75}
76 76
77function addRemoteVideo (videoToCreateData, fromPod, finalCallback) { 77function addRemoteVideo (videoToCreateData, fromPod, finalCallback) {
@@ -79,11 +79,7 @@ function addRemoteVideo (videoToCreateData, fromPod, finalCallback) {
79 79
80 waterfall([ 80 waterfall([
81 81
82 function startTransaction (callback) { 82 databaseUtils.startSerializableTransaction,
83 db.sequelize.transaction({ isolationLevel: 'SERIALIZABLE' }).asCallback(function (err, t) {
84 return callback(err, t)
85 })
86 },
87 83
88 function findOrCreateAuthor (t, callback) { 84 function findOrCreateAuthor (t, callback) {
89 const name = videoToCreateData.author 85 const name = videoToCreateData.author
@@ -180,7 +176,7 @@ function updateRemoteVideoRetryWrapper (videoAttributesToUpdate, fromPod, finalC
180 errorMessage: 'Cannot update the remote video with many retries' 176 errorMessage: 'Cannot update the remote video with many retries'
181 } 177 }
182 178
183 utils.retryWrapper(updateRemoteVideo, options, finalCallback) 179 databaseUtils.retryWrapper(updateRemoteVideo, options, finalCallback)
184} 180}
185 181
186function updateRemoteVideo (videoAttributesToUpdate, fromPod, finalCallback) { 182function updateRemoteVideo (videoAttributesToUpdate, fromPod, finalCallback) {
@@ -188,11 +184,7 @@ function updateRemoteVideo (videoAttributesToUpdate, fromPod, finalCallback) {
188 184
189 waterfall([ 185 waterfall([
190 186
191 function startTransaction (callback) { 187 databaseUtils.startSerializableTransaction,
192 db.sequelize.transaction({ isolationLevel: 'SERIALIZABLE' }).asCallback(function (err, t) {
193 return callback(err, t)
194 })
195 },
196 188
197 function findVideo (t, callback) { 189 function findVideo (t, callback) {
198 fetchVideo(fromPod.host, videoAttributesToUpdate.remoteId, function (err, videoInstance) { 190 fetchVideo(fromPod.host, videoAttributesToUpdate.remoteId, function (err, videoInstance) {