aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/videos.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/api/videos.js')
-rw-r--r--server/controllers/api/videos.js46
1 files changed, 20 insertions, 26 deletions
diff --git a/server/controllers/api/videos.js b/server/controllers/api/videos.js
index 2c4af520e..9a50a29be 100644
--- a/server/controllers/api/videos.js
+++ b/server/controllers/api/videos.js
@@ -106,20 +106,17 @@ module.exports = router
106// Wrapper to video add that retry the function if there is a database error 106// Wrapper to video add that retry the function if there is a database error
107// We need this because we run the transaction in SERIALIZABLE isolation that can fail 107// We need this because we run the transaction in SERIALIZABLE isolation that can fail
108function addVideoRetryWrapper (req, res, next) { 108function addVideoRetryWrapper (req, res, next) {
109 utils.transactionRetryer( 109 const options = {
110 function (callback) { 110 arguments: [ req, res, req.files.videofile[0] ],
111 return addVideo(req, res, req.files.videofile[0], callback) 111 errorMessage: 'Cannot insert the video with many retries.'
112 }, 112 }
113 function (err) {
114 if (err) {
115 logger.error('Cannot insert the video with many retries.', { error: err })
116 return next(err)
117 }
118 113
119 // TODO : include Location of the new video -> 201 114 utils.retryWrapper(addVideo, options, function (err) {
120 return res.type('json').status(204).end() 115 if (err) return next(err)
121 } 116
122 ) 117 // TODO : include Location of the new video -> 201
118 return res.type('json').status(204).end()
119 })
123} 120}
124 121
125function addVideo (req, res, videoFile, callback) { 122function addVideo (req, res, videoFile, callback) {
@@ -241,20 +238,17 @@ function addVideo (req, res, videoFile, callback) {
241} 238}
242 239
243function updateVideoRetryWrapper (req, res, next) { 240function updateVideoRetryWrapper (req, res, next) {
244 utils.transactionRetryer( 241 const options = {
245 function (callback) { 242 arguments: [ req, res ],
246 return updateVideo(req, res, callback) 243 errorMessage: 'Cannot update the video with many retries.'
247 }, 244 }
248 function (err) {
249 if (err) {
250 logger.error('Cannot update the video with many retries.', { error: err })
251 return next(err)
252 }
253 245
254 // TODO : include Location of the new video -> 201 246 utils.retryWrapper(updateVideo, options, function (err) {
255 return res.type('json').status(204).end() 247 if (err) return next(err)
256 } 248
257 ) 249 // TODO : include Location of the new video -> 201
250 return res.type('json').status(204).end()
251 })
258} 252}
259 253
260function updateVideo (req, res, finalCallback) { 254function updateVideo (req, res, finalCallback) {