Check for closed database and cancel sync

This can prevent a long hang if there's a shutdown during sync.
This commit is contained in:
Dan Stillman 2016-04-22 20:17:19 -04:00
parent d3fc4eb554
commit 121a2f79a8
2 changed files with 5 additions and 0 deletions

View File

@ -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;

View File

@ -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;
}