From b4121ee6bc7d6edd0a64ab311c3d3e2e97ff6a89 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Mon, 14 Oct 2019 01:27:59 -0400 Subject: [PATCH] Don't show error icon when file sync is cancelled --- .../content/zotero/xpcom/storage/storageEngine.js | 7 ++++++- chrome/content/zotero/xpcom/storage/zfs.js | 13 ++++++++----- chrome/content/zotero/xpcom/sync/syncRunner.js | 5 +++++ 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/chrome/content/zotero/xpcom/storage/storageEngine.js b/chrome/content/zotero/xpcom/storage/storageEngine.js index 59f2627d01..9ba53726b6 100644 --- a/chrome/content/zotero/xpcom/storage/storageEngine.js +++ b/chrome/content/zotero/xpcom/storage/storageEngine.js @@ -229,8 +229,13 @@ Zotero.Sync.Storage.Engine.prototype.start = Zotero.Promise.coroutine(function* succeeded++; } else if (!p.isPending()) { + let e = p.reason(); + if (e instanceof Zotero.HTTP.CancelledException) { + Zotero.debug(`File ${type} sync cancelled for ${this.library.name} ` + + `(${succeeded} succeeded, ${failed} failed)`); + throw new Zotero.Sync.UserCancelledException(); + } if (this.stopOnError) { - let e = p.reason(); Zotero.debug(`File ${type} sync failed for ${this.library.name}`); throw e; } diff --git a/chrome/content/zotero/xpcom/storage/zfs.js b/chrome/content/zotero/xpcom/storage/zfs.js index 37d3720ec4..a982e6490c 100644 --- a/chrome/content/zotero/xpcom/storage/zfs.js +++ b/chrome/content/zotero/xpcom/storage/zfs.js @@ -751,11 +751,14 @@ Zotero.Sync.Storage.Mode.ZFS.prototype = { ); } catch (e) { - let msg = `Unexpected file registration status ${e.status} (${item.libraryKey})`; - Zotero.logError(msg); - Zotero.logError(e.xmlhttp.responseText); - Zotero.debug(e.xmlhttp.getAllResponseHeaders()); - throw new Error(Zotero.Sync.Storage.defaultError); + if (e instanceof Zotero.HTTP.UnexpectedStatusException) { + let msg = `Unexpected file registration status ${e.status} (${item.libraryKey})`; + Zotero.logError(msg); + Zotero.logError(e.xmlhttp.responseText); + Zotero.debug(e.xmlhttp.getAllResponseHeaders()); + throw new Error(Zotero.Sync.Storage.defaultError); + } + throw e; } var version = req.getResponseHeader('Last-Modified-Version'); diff --git a/chrome/content/zotero/xpcom/sync/syncRunner.js b/chrome/content/zotero/xpcom/sync/syncRunner.js index 682bac2e1e..a5a8d51c95 100644 --- a/chrome/content/zotero/xpcom/sync/syncRunner.js +++ b/chrome/content/zotero/xpcom/sync/syncRunner.js @@ -209,6 +209,11 @@ Zotero.Sync.Runner_Module = function (options = {}) { setStatus: this.setSyncStatus.bind(this), stopOnError, onError: function (e) { + // Ignore cancelled requests + if (e instanceof Zotero.HTTP.CancelledException) { + Zotero.debug("Request was cancelled"); + return; + } if (options.onError) { options.onError(e); }