aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/database-utils.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2023-05-19 10:10:41 +0200
committerChocobozzz <me@florianbigard.com>2023-05-19 10:10:41 +0200
commit472170b4f923a52cceb595221864eab61d624d5b (patch)
treed466b9e7b4f0eb54bffb30250f66b604bf907768 /server/helpers/database-utils.ts
parent26172955691acd6d7b682647dda6b2109e426c51 (diff)
downloadPeerTube-472170b4f923a52cceb595221864eab61d624d5b.tar.gz
PeerTube-472170b4f923a52cceb595221864eab61d624d5b.tar.zst
PeerTube-472170b4f923a52cceb595221864eab61d624d5b.zip
Avoid aborting completing jobs
Diffstat (limited to 'server/helpers/database-utils.ts')
-rw-r--r--server/helpers/database-utils.ts9
1 files changed, 9 insertions, 0 deletions
diff --git a/server/helpers/database-utils.ts b/server/helpers/database-utils.ts
index da8fb0d54..b6ba7fd75 100644
--- a/server/helpers/database-utils.ts
+++ b/server/helpers/database-utils.ts
@@ -68,6 +68,14 @@ function transactionRetryer <T> (func: (err: any, data: T) => any) {
68 }) 68 })
69} 69}
70 70
71function saveInTransactionWithRetries <T extends Pick<Model, 'save'>> (model: T) {
72 return retryTransactionWrapper(() => {
73 return sequelizeTypescript.transaction(async transaction => {
74 await model.save({ transaction })
75 })
76 })
77}
78
71// --------------------------------------------------------------------------- 79// ---------------------------------------------------------------------------
72 80
73function resetSequelizeInstance <T> (instance: Model<T>) { 81function resetSequelizeInstance <T> (instance: Model<T>) {
@@ -105,6 +113,7 @@ export {
105 resetSequelizeInstance, 113 resetSequelizeInstance,
106 retryTransactionWrapper, 114 retryTransactionWrapper,
107 transactionRetryer, 115 transactionRetryer,
116 saveInTransactionWithRetries,
108 afterCommitIfTransaction, 117 afterCommitIfTransaction,
109 filterNonExistingModels, 118 filterNonExistingModels,
110 deleteAllModels, 119 deleteAllModels,