From 7b0ed6da8167873a8f67a5d36fad30be99e6539f Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sat, 5 Aug 2017 01:07:49 +0200 Subject: [PATCH] Don't unlink account on key info request connection failure This can happen when the computer is offline but that hasn't been detected for some reason. --- chrome/content/zotero/preferences/preferences_sync.js | 4 +--- chrome/content/zotero/xpcom/sync/syncAPIClient.js | 2 +- chrome/content/zotero/xpcom/sync/syncRunner.js | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/chrome/content/zotero/preferences/preferences_sync.js b/chrome/content/zotero/preferences/preferences_sync.js index 6c94482bf..2773784f9 100644 --- a/chrome/content/zotero/preferences/preferences_sync.js +++ b/chrome/content/zotero/preferences/preferences_sync.js @@ -51,9 +51,7 @@ Zotero_Preferences.Sync = { } catch (e) { // API key wrong/invalid - if (!(e instanceof Zotero.HTTP.UnexpectedStatusException) - && !(e instanceof Zotero.HTTP.TimeoutException) - && !(e instanceof Zotero.HTTP.BrowserOfflineException)) { + if (e instanceof Zotero.Error && e.error == Zotero.Error.ERROR_API_KEY_INVALID) { Zotero.alert( window, Zotero.getString('general.error'), diff --git a/chrome/content/zotero/xpcom/sync/syncAPIClient.js b/chrome/content/zotero/xpcom/sync/syncAPIClient.js index 4e302dcbf..802f085ea 100644 --- a/chrome/content/zotero/xpcom/sync/syncAPIClient.js +++ b/chrome/content/zotero/xpcom/sync/syncAPIClient.js @@ -55,7 +55,7 @@ Zotero.Sync.APIClient.prototype = { Object.assign(opts, options); opts.successCodes = [200, 403, 404]; var xmlhttp = yield this.makeRequest("GET", uri, opts); - if (xmlhttp.status == 403 || xmlhttp.status == 404) { + if (xmlhttp.status == 403) { return false; } var json = this._parseJSON(xmlhttp.responseText); diff --git a/chrome/content/zotero/xpcom/sync/syncRunner.js b/chrome/content/zotero/xpcom/sync/syncRunner.js index 5cab5de5e..f1f6184d9 100644 --- a/chrome/content/zotero/xpcom/sync/syncRunner.js +++ b/chrome/content/zotero/xpcom/sync/syncRunner.js @@ -269,7 +269,7 @@ Zotero.Sync.Runner_Module = function (options = {}) { var json = yield client.getKeyInfo(options); Zotero.debug(json); if (!json) { - throw new Zotero.Error("API key not set", Zotero.Error.ERROR_API_KEY_NOT_SET); + throw new Zotero.Error("API key not set", Zotero.Error.ERROR_API_KEY_INVALID); } // Sanity check