aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-01-17 20:38:45 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-01-17 20:50:45 +0100
commit4145c1c68923c13538a5b60d1b384037d0dded9d (patch)
tree36471645006f47d1118fcba59a4f5d3e84598856 /server/helpers
parent98dffd102ef76872f027fedfc55cc0dc824b5bad (diff)
downloadPeerTube-4145c1c68923c13538a5b60d1b384037d0dded9d.tar.gz
PeerTube-4145c1c68923c13538a5b60d1b384037d0dded9d.tar.zst
PeerTube-4145c1c68923c13538a5b60d1b384037d0dded9d.zip
Server: transaction refractoring
Diffstat (limited to 'server/helpers')
-rw-r--r--server/helpers/database-utils.js22
1 files changed, 20 insertions, 2 deletions
diff --git a/server/helpers/database-utils.js b/server/helpers/database-utils.js
index 046717517..6fe7e99aa 100644
--- a/server/helpers/database-utils.js
+++ b/server/helpers/database-utils.js
@@ -6,9 +6,27 @@ const db = require('../initializers/database')
6const logger = require('./logger') 6const logger = require('./logger')
7 7
8const utils = { 8const utils = {
9 commitTransaction,
9 retryTransactionWrapper, 10 retryTransactionWrapper,
10 transactionRetryer, 11 rollbackTransaction,
11 startSerializableTransaction 12 startSerializableTransaction,
13 transactionRetryer
14}
15
16function commitTransaction (t, callback) {
17 return t.commit().asCallback(callback)
18}
19
20function rollbackTransaction (err, t, callback) {
21 // Try to rollback transaction
22 if (t) {
23 // Do not catch err, report the original one
24 t.rollback().asCallback(function () {
25 return callback(err)
26 })
27 } else {
28 return callback(err)
29 }
12} 30}
13 31
14// { arguments, errorMessage } 32// { arguments, errorMessage }