diff --git a/chrome/content/zotero/xpcom/db.js b/chrome/content/zotero/xpcom/db.js index 9f386e6e6a..27c65cb6d3 100644 --- a/chrome/content/zotero/xpcom/db.js +++ b/chrome/content/zotero/xpcom/db.js @@ -465,6 +465,15 @@ Zotero.DBConnection.prototype.executeTransaction = Zotero.Promise.coroutine(func } } + try { + var result = yield Zotero.Promise.coroutine(func)(); + } + catch (e) { + Zotero.debug("Rolled back nested async DB transaction", 5); + this._asyncTransactionNestingLevel = 0; + throw e; + } + Zotero.debug("Decreasing async DB transaction level to " + --this._asyncTransactionNestingLevel, 5); return result; @@ -489,78 +498,77 @@ Zotero.DBConnection.prototype.executeTransaction = Zotero.Promise.coroutine(func } } var result = yield conn.executeTransaction(func); - try { - Zotero.debug("Committed async DB transaction", 5); - - // Clear transaction time - if (this._transactionDate) { - this._transactionDate = null; - } - - if (options) { - // Function to run once transaction has been committed but before any - // permanent callbacks - if (options.onCommit) { - this._callbacks.current.commit.push(options.onCommit); - } - this._callbacks.current.rollback = []; - - if (options.vacuumOnCommit) { - Zotero.debug('Vacuuming database'); - yield Zotero.DB.queryAsync('VACUUM'); - } - } - - // Run temporary commit callbacks - var f; - while (f = this._callbacks.current.commit.shift()) { - yield Zotero.Promise.resolve(f()); - } - - // Run commit callbacks - for (var i=0; i