diff options
author | Chocobozzz <me@florianbigard.com> | 2019-07-29 11:59:29 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-07-29 13:40:39 +0200 |
commit | 2284f202070aa2e49156cc52b3b1596a7d5aadec (patch) | |
tree | 77aeb00016734667f8ff32a98ea8b4a6ed3ca31e /server/helpers/database-utils.ts | |
parent | 112be80ebdf96ef6a27420c1c6a10097388731a9 (diff) | |
download | PeerTube-2284f202070aa2e49156cc52b3b1596a7d5aadec.tar.gz PeerTube-2284f202070aa2e49156cc52b3b1596a7d5aadec.tar.zst PeerTube-2284f202070aa2e49156cc52b3b1596a7d5aadec.zip |
Add gitlab ci support
Diffstat (limited to 'server/helpers/database-utils.ts')
-rw-r--r-- | server/helpers/database-utils.ts | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/server/helpers/database-utils.ts b/server/helpers/database-utils.ts index 39c74b2fd..6c5068fb0 100644 --- a/server/helpers/database-utils.ts +++ b/server/helpers/database-utils.ts | |||
@@ -2,6 +2,7 @@ import * as retry from 'async/retry' | |||
2 | import * as Bluebird from 'bluebird' | 2 | import * as Bluebird from 'bluebird' |
3 | import { Model } from 'sequelize-typescript' | 3 | import { Model } from 'sequelize-typescript' |
4 | import { logger } from './logger' | 4 | import { logger } from './logger' |
5 | import { Transaction } from 'sequelize' | ||
5 | 6 | ||
6 | function retryTransactionWrapper <T, A, B, C> ( | 7 | function retryTransactionWrapper <T, A, B, C> ( |
7 | functionToRetry: (arg1: A, arg2: B, arg3: C) => Promise<T> | Bluebird<T>, | 8 | functionToRetry: (arg1: A, arg2: B, arg3: C) => Promise<T> | Bluebird<T>, |
@@ -72,11 +73,18 @@ function resetSequelizeInstance (instance: Model<any>, savedFields: object) { | |||
72 | }) | 73 | }) |
73 | } | 74 | } |
74 | 75 | ||
76 | function afterCommitIfTransaction (t: Transaction, fn: Function) { | ||
77 | if (t) return t.afterCommit(() => fn()) | ||
78 | |||
79 | return fn() | ||
80 | } | ||
81 | |||
75 | // --------------------------------------------------------------------------- | 82 | // --------------------------------------------------------------------------- |
76 | 83 | ||
77 | export { | 84 | export { |
78 | resetSequelizeInstance, | 85 | resetSequelizeInstance, |
79 | retryTransactionWrapper, | 86 | retryTransactionWrapper, |
80 | transactionRetryer, | 87 | transactionRetryer, |
81 | updateInstanceWithAnother | 88 | updateInstanceWithAnother, |
89 | afterCommitIfTransaction | ||
82 | } | 90 | } |