1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-04 02:09:37 +02:00

Server: try to have a better video integrity

This commit is contained in:
Chocobozzz 2017-01-06 23:24:47 +01:00
parent bb0b243c92
commit ed04d94f6d
6 changed files with 194 additions and 71 deletions

View file

@ -1,6 +1,7 @@
'use strict'
const crypto = require('crypto')
const retry = require('async/retry')
const logger = require('./logger')
@ -9,7 +10,8 @@ const utils = {
cleanForExit,
generateRandomString,
isTestInstance,
getFormatedObjects
getFormatedObjects,
transactionRetryer
}
function badRequest (req, res, next) {
@ -46,6 +48,18 @@ function getFormatedObjects (objects, objectsTotal) {
}
}
function transactionRetryer (func, callback) {
retry({
times: 5,
errorFilter: function (err) {
const willRetry = (err.name === 'SequelizeDatabaseError')
logger.debug('Maybe retrying the transaction function.', { willRetry })
return willRetry
}
}, func, callback)
}
// ---------------------------------------------------------------------------
module.exports = utils