From 121a2f79a8f67fbd96278e2cf76c5827c5cf69a2 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Fri, 22 Apr 2016 20:17:19 -0400 Subject: [PATCH] Check for closed database and cancel sync This can prevent a long hang if there's a shutdown during sync. --- chrome/content/zotero/xpcom/db.js | 2 ++ chrome/content/zotero/xpcom/sync/syncLocal.js | 3 +++ 2 files changed, 5 insertions(+) diff --git a/chrome/content/zotero/xpcom/db.js b/chrome/content/zotero/xpcom/db.js index 2dd50478e..ca007d93c 100644 --- a/chrome/content/zotero/xpcom/db.js +++ b/chrome/content/zotero/xpcom/db.js @@ -40,6 +40,7 @@ Zotero.DBConnection = function(dbName) { Components.utils.import("resource://gre/modules/Sqlite.jsm", this); + this.closed = false; this.skipBackup = false; this.transactionVacuum = false; @@ -913,6 +914,7 @@ Zotero.DBConnection.prototype.checkException = function (e) { Zotero.DBConnection.prototype.closeDatabase = Zotero.Promise.coroutine(function* (permanent) { if (this._connection) { Zotero.debug("Closing database"); + this.closed = true; yield this._connection.close(); this._connection = undefined; this._connection = permanent ? false : null; diff --git a/chrome/content/zotero/xpcom/sync/syncLocal.js b/chrome/content/zotero/xpcom/sync/syncLocal.js index 60db984dc..81a623aa3 100644 --- a/chrome/content/zotero/xpcom/sync/syncLocal.js +++ b/chrome/content/zotero/xpcom/sync/syncLocal.js @@ -670,6 +670,9 @@ Zotero.Sync.Data.Local = { options.onError(e); } + if (Zotero.DB.closed) { + e.fatal = true; + } if (options.stopOnError || e.fatal) { throw e; }