aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/database-utils.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-07-11 17:04:57 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-07-11 17:05:55 +0200
commit075f16caac5236cb04c98ae7b3a989766d764bb3 (patch)
tree9a30024aa771735a28d83d9a166033b82dbcaf60 /server/helpers/database-utils.ts
parent4e979c3e1b81f4762025d9db3052b1f70774b3bb (diff)
downloadPeerTube-075f16caac5236cb04c98ae7b3a989766d764bb3.tar.gz
PeerTube-075f16caac5236cb04c98ae7b3a989766d764bb3.tar.zst
PeerTube-075f16caac5236cb04c98ae7b3a989766d764bb3.zip
Remove "function" in favor of () => {}
Diffstat (limited to 'server/helpers/database-utils.ts')
-rw-r--r--server/helpers/database-utils.ts14
1 files changed, 5 insertions, 9 deletions
diff --git a/server/helpers/database-utils.ts b/server/helpers/database-utils.ts
index e174dc3e9..987e42eb0 100644
--- a/server/helpers/database-utils.ts
+++ b/server/helpers/database-utils.ts
@@ -8,13 +8,11 @@ type RetryTransactionWrapperOptions = { errorMessage: string, arguments?: any[]
8function retryTransactionWrapper (functionToRetry: (... args) => Promise<any>, options: RetryTransactionWrapperOptions) { 8function retryTransactionWrapper (functionToRetry: (... args) => Promise<any>, options: RetryTransactionWrapperOptions) {
9 const args = options.arguments ? options.arguments : [] 9 const args = options.arguments ? options.arguments : []
10 10
11 return transactionRetryer( 11 return transactionRetryer(callback => {
12 function (callback) { 12 functionToRetry.apply(this, args)
13 functionToRetry.apply(this, args)
14 .then(result => callback(null, result)) 13 .then(result => callback(null, result))
15 .catch(err => callback(err)) 14 .catch(err => callback(err))
16 } 15 })
17 )
18 .catch(err => { 16 .catch(err => {
19 // Do not throw the error, continue the process 17 // Do not throw the error, continue the process
20 logger.error(options.errorMessage, err) 18 logger.error(options.errorMessage, err)
@@ -26,14 +24,12 @@ function transactionRetryer (func: Function) {
26 retry({ 24 retry({
27 times: 5, 25 times: 5,
28 26
29 errorFilter: function (err) { 27 errorFilter: err => {
30 const willRetry = (err.name === 'SequelizeDatabaseError') 28 const willRetry = (err.name === 'SequelizeDatabaseError')
31 logger.debug('Maybe retrying the transaction function.', { willRetry }) 29 logger.debug('Maybe retrying the transaction function.', { willRetry })
32 return willRetry 30 return willRetry
33 } 31 }
34 }, func, function (err) { 32 }, func, err => err ? rej(err) : res())
35 err ? rej(err) : res()
36 })
37 }) 33 })
38} 34}
39 35