diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-01-06 23:24:47 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-01-06 23:46:36 +0100 |
commit | ed04d94f6d7132055f97a2f757b85c03c5f2a0b6 (patch) | |
tree | 2f1f8c6f6e46b9ab18ba009403f80b14af61af68 /server/helpers/utils.js | |
parent | bb0b243c92577872a5f4d98f707e078082af4d2a (diff) | |
download | PeerTube-ed04d94f6d7132055f97a2f757b85c03c5f2a0b6.tar.gz PeerTube-ed04d94f6d7132055f97a2f757b85c03c5f2a0b6.tar.zst PeerTube-ed04d94f6d7132055f97a2f757b85c03c5f2a0b6.zip |
Server: try to have a better video integrity
Diffstat (limited to 'server/helpers/utils.js')
-rw-r--r-- | server/helpers/utils.js | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/server/helpers/utils.js b/server/helpers/utils.js index 9f4b14582..a902850cd 100644 --- a/server/helpers/utils.js +++ b/server/helpers/utils.js | |||
@@ -1,6 +1,7 @@ | |||
1 | 'use strict' | 1 | 'use strict' |
2 | 2 | ||
3 | const crypto = require('crypto') | 3 | const crypto = require('crypto') |
4 | const retry = require('async/retry') | ||
4 | 5 | ||
5 | const logger = require('./logger') | 6 | const logger = require('./logger') |
6 | 7 | ||
@@ -9,7 +10,8 @@ const utils = { | |||
9 | cleanForExit, | 10 | cleanForExit, |
10 | generateRandomString, | 11 | generateRandomString, |
11 | isTestInstance, | 12 | isTestInstance, |
12 | getFormatedObjects | 13 | getFormatedObjects, |
14 | transactionRetryer | ||
13 | } | 15 | } |
14 | 16 | ||
15 | function badRequest (req, res, next) { | 17 | function badRequest (req, res, next) { |
@@ -46,6 +48,18 @@ function getFormatedObjects (objects, objectsTotal) { | |||
46 | } | 48 | } |
47 | } | 49 | } |
48 | 50 | ||
51 | function transactionRetryer (func, callback) { | ||
52 | retry({ | ||
53 | times: 5, | ||
54 | |||
55 | errorFilter: function (err) { | ||
56 | const willRetry = (err.name === 'SequelizeDatabaseError') | ||
57 | logger.debug('Maybe retrying the transaction function.', { willRetry }) | ||
58 | return willRetry | ||
59 | } | ||
60 | }, func, callback) | ||
61 | } | ||
62 | |||
49 | // --------------------------------------------------------------------------- | 63 | // --------------------------------------------------------------------------- |
50 | 64 | ||
51 | module.exports = utils | 65 | module.exports = utils |