mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-04 18:29:27 +02:00
Server: transaction refractoring
This commit is contained in:
parent
98dffd102e
commit
4145c1c689
3 changed files with 68 additions and 84 deletions
|
@ -6,9 +6,27 @@ const db = require('../initializers/database')
|
|||
const logger = require('./logger')
|
||||
|
||||
const utils = {
|
||||
commitTransaction,
|
||||
retryTransactionWrapper,
|
||||
transactionRetryer,
|
||||
startSerializableTransaction
|
||||
rollbackTransaction,
|
||||
startSerializableTransaction,
|
||||
transactionRetryer
|
||||
}
|
||||
|
||||
function commitTransaction (t, callback) {
|
||||
return t.commit().asCallback(callback)
|
||||
}
|
||||
|
||||
function rollbackTransaction (err, t, callback) {
|
||||
// Try to rollback transaction
|
||||
if (t) {
|
||||
// Do not catch err, report the original one
|
||||
t.rollback().asCallback(function () {
|
||||
return callback(err)
|
||||
})
|
||||
} else {
|
||||
return callback(err)
|
||||
}
|
||||
}
|
||||
|
||||
// { arguments, errorMessage }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue