]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/helpers/database-utils.ts
Set correctly preview image for open graph
[github/Chocobozzz/PeerTube.git] / server / helpers / database-utils.ts
index e174dc3e960594ee7e6e2412ec09b5f6d9f9bd02..987e42eb074a0441fab5f2c43aa6d646ea0054c6 100644 (file)
@@ -8,13 +8,11 @@ type RetryTransactionWrapperOptions = { errorMessage: string, arguments?: any[]
 function retryTransactionWrapper (functionToRetry: (... args) => Promise<any>, options: RetryTransactionWrapperOptions) {
   const args = options.arguments ? options.arguments : []
 
-  return transactionRetryer(
-    function (callback) {
-      functionToRetry.apply(this, args)
+  return transactionRetryer(callback => {
+    functionToRetry.apply(this, args)
         .then(result => callback(null, result))
         .catch(err => callback(err))
-    }
-  )
+  })
   .catch(err => {
     // Do not throw the error, continue the process
     logger.error(options.errorMessage, err)
@@ -26,14 +24,12 @@ function transactionRetryer (func: Function) {
     retry({
       times: 5,
 
-      errorFilter: function (err) {
+      errorFilter: err => {
         const willRetry = (err.name === 'SequelizeDatabaseError')
         logger.debug('Maybe retrying the transaction function.', { willRetry })
         return willRetry
       }
-    }, func, function (err) {
-      err ? rej(err) : res()
-    })
+    }, func, err => err ? rej(err) : res())
   })
 }