commit 121a2f79a8f67fbd96278e2cf76c5827c5cf69a2
parent d3fc4eb554a306679f4c9dc254434f85205aa543
Author: Dan Stillman <dstillman@zotero.org>
Date: Fri, 22 Apr 2016 20:17:19 -0400
Check for closed database and cancel sync
This can prevent a long hang if there's a shutdown during sync.
Diffstat:
2 files changed, 5 insertions(+), 0 deletions(-)
diff --git 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
@@ -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;
}