mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-08-07 14:23:53 +00:00
Unconditionally decrement transaction depth (#8008)
…otherwise we may end up in a situation where we're always stuck in an "already in a transaction" state and often neglect to actually enter a real transaction!
This commit is contained in:
parent
d7d0733177
commit
de4fe132a7
@ -507,6 +507,7 @@ TODO: better-sqlite3 provides its own transaction method which we should be usin
|
|||||||
SqlTiddlerDatabase.prototype.transaction = function(fn) {
|
SqlTiddlerDatabase.prototype.transaction = function(fn) {
|
||||||
const alreadyInTransaction = this.transactionDepth > 0;
|
const alreadyInTransaction = this.transactionDepth > 0;
|
||||||
this.transactionDepth++;
|
this.transactionDepth++;
|
||||||
|
try {
|
||||||
if(alreadyInTransaction) {
|
if(alreadyInTransaction) {
|
||||||
return fn();
|
return fn();
|
||||||
} else {
|
} else {
|
||||||
@ -517,11 +518,12 @@ SqlTiddlerDatabase.prototype.transaction = function(fn) {
|
|||||||
} catch(e) {
|
} catch(e) {
|
||||||
this.runStatement(`ROLLBACK TRANSACTION`);
|
this.runStatement(`ROLLBACK TRANSACTION`);
|
||||||
throw(e);
|
throw(e);
|
||||||
} finally {
|
|
||||||
this.transactionDepth--;
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
this.transactionDepth--;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.SqlTiddlerDatabase = SqlTiddlerDatabase;
|
exports.SqlTiddlerDatabase = SqlTiddlerDatabase;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user