commit af7da366c9478c0f63b04dd9d20a21ff2a75b859 parent a39a42546f11a86249fc441725f6d4a48c86bd75 Author: Dan Stillman <dstillman@zotero.org> Date: Sun, 10 May 2015 02:54:38 -0400 Get connection without yielding if available in executeTransaction Diffstat:
| M | chrome/content/zotero/xpcom/db.js | | | 12 | +++++++++++- |
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/chrome/content/zotero/xpcom/db.js b/chrome/content/zotero/xpcom/db.js @@ -501,7 +501,7 @@ Zotero.DBConnection.prototype.executeTransaction = Zotero.Promise.coroutine(func this._callbacks.begin[i](); } } - var conn = yield this._getConnectionAsync(options); + var conn = this._getConnection(options) || (yield this._getConnectionAsync(options)); var result = yield conn.executeTransaction(func); Zotero.debug("Committed async DB transaction", 5); this._inTransaction = false; @@ -1111,6 +1111,16 @@ Zotero.DBConnection.prototype.getSQLDataType = function(value) { // ///////////////////////////////////////////////////////////////// +Zotero.DBConnection.prototype._getConnection = function (options) { + if (this._backupPromise && this._backupPromise.isPending() && (!options || !options.inBackup)) { + return false; + } + if (this._connectionAsync === false) { + throw new Error("Database permanently closed; not re-opening"); + } + return this._connectionAsync || false; +} + /* * Retrieve a link to the data store asynchronously */