From 254695f4b318775c2d5c6d592405b35164f75fe2 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sun, 7 Feb 2021 16:38:14 -0500 Subject: [PATCH] Skip extra sync download after some conflicts If an upload fails with a 412, and then we download, and then we go to upload but there was nothing to upload (e.g., because the remote version was chosen or there was an error saving it), there's no reason to do a download again after that. --- chrome/content/zotero/xpcom/sync/syncEngine.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/chrome/content/zotero/xpcom/sync/syncEngine.js b/chrome/content/zotero/xpcom/sync/syncEngine.js index 0f3ebebe1f..80a24a8c3e 100644 --- a/chrome/content/zotero/xpcom/sync/syncEngine.js +++ b/chrome/content/zotero/xpcom/sync/syncEngine.js @@ -133,6 +133,7 @@ Zotero.Sync.Data.Engine.prototype.start = Zotero.Promise.coroutine(function* () this.downloadDelayGenerator = null; var autoReset = false; + var skipDownload = false; sync: while (true) { @@ -173,6 +174,9 @@ Zotero.Sync.Data.Engine.prototype.start = Zotero.Promise.coroutine(function* () break; case this.UPLOAD_RESULT_NOTHING_TO_UPLOAD: + if (skipDownload) { + break sync; + } downloadResult = yield this._startDownload(); Zotero.debug("Download result is " + downloadResult, 4); if (downloadResult == this.DOWNLOAD_RESULT_CHANGES_TO_UPLOAD) { @@ -198,6 +202,10 @@ Zotero.Sync.Data.Engine.prototype.start = Zotero.Promise.coroutine(function* () downloadResult = yield this._startDownload(); Zotero.debug("Download result is " + downloadResult, 4); + // No need to download again after the upload + if (downloadResult !== this.DOWNLOAD_RESULT_RESTART) { + skipDownload = true; + } break; case this.UPLOAD_RESULT_RESTART: