diff --git a/chrome/content/zotero/xpcom/db.js b/chrome/content/zotero/xpcom/db.js index e9d70166a..ee7be6def 100644 --- 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 */