X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fcontrollers%2Fapi%2Fvideos.js;h=9a50a29bef5065e04fc39b12cc7aa20ca48b04c7;hb=d6a5b018b89f9d2569ca7435b0e270095c93cc17;hp=2c4af520e65f62ae2f1c98f4e90b131bbf18e45e;hpb=a7721e62c028f54c1d165b53ac1a7a60b6c3b82e;p=github%2FChocobozzz%2FPeerTube.git 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 // Wrapper to video add that retry the function if there is a database error // We need this because we run the transaction in SERIALIZABLE isolation that can fail function addVideoRetryWrapper (req, res, next) { - utils.transactionRetryer( - function (callback) { - return addVideo(req, res, req.files.videofile[0], callback) - }, - function (err) { - if (err) { - logger.error('Cannot insert the video with many retries.', { error: err }) - return next(err) - } + const options = { + arguments: [ req, res, req.files.videofile[0] ], + errorMessage: 'Cannot insert the video with many retries.' + } - // TODO : include Location of the new video -> 201 - return res.type('json').status(204).end() - } - ) + utils.retryWrapper(addVideo, options, function (err) { + if (err) return next(err) + + // TODO : include Location of the new video -> 201 + return res.type('json').status(204).end() + }) } function addVideo (req, res, videoFile, callback) { @@ -241,20 +238,17 @@ function addVideo (req, res, videoFile, callback) { } function updateVideoRetryWrapper (req, res, next) { - utils.transactionRetryer( - function (callback) { - return updateVideo(req, res, callback) - }, - function (err) { - if (err) { - logger.error('Cannot update the video with many retries.', { error: err }) - return next(err) - } + const options = { + arguments: [ req, res ], + errorMessage: 'Cannot update the video with many retries.' + } - // TODO : include Location of the new video -> 201 - return res.type('json').status(204).end() - } - ) + utils.retryWrapper(updateVideo, options, function (err) { + if (err) return next(err) + + // TODO : include Location of the new video -> 201 + return res.type('json').status(204).end() + }) } function updateVideo (req, res, finalCallback) {