1
0
Fork 0
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:
Chocobozzz 2017-01-17 20:38:45 +01:00
parent 98dffd102e
commit 4145c1c689
3 changed files with 68 additions and 84 deletions

View file

@ -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 }