From b41734924d517f3a48c9e8419350d79fd0b1878a Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sun, 16 Feb 2020 18:02:37 -0500 Subject: [PATCH] Further fixing of "Too many sync requests" error Follow-up to 804a898c98 Addresses #1788 --- chrome/content/zotero/xpcom/storage/zfs.js | 4 ++-- chrome/content/zotero/xpcom/sync/syncEngine.js | 4 ++-- chrome/content/zotero/xpcom/sync/syncLocal.js | 10 ++++++++-- test/tests/zfsTest.js | 2 +- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/chrome/content/zotero/xpcom/storage/zfs.js b/chrome/content/zotero/xpcom/storage/zfs.js index 31fefee6c7..794b5cbad6 100644 --- a/chrome/content/zotero/xpcom/storage/zfs.js +++ b/chrome/content/zotero/xpcom/storage/zfs.js @@ -536,7 +536,7 @@ Zotero.Sync.Storage.Mode.ZFS.prototype = { // Mark object for redownloading, in case the library version is up to date and // it's just the attachment item that somehow didn't get updated yield Zotero.Sync.Data.Local.addObjectsToSyncQueue( - 'item', item.libraryID, [item.key] + 'item', item.libraryID, [item.key], true ); return new Zotero.Sync.Storage.Result({ syncRequired: true @@ -566,7 +566,7 @@ Zotero.Sync.Storage.Mode.ZFS.prototype = { // Mark object for redownloading, in case the library version is up to date and // it's just the attachment item that somehow didn't get updated yield Zotero.Sync.Data.Local.addObjectsToSyncQueue( - 'item', item.libraryID, [item.key] + 'item', item.libraryID, [item.key], true ); return new Zotero.Sync.Storage.Result({ syncRequired: true diff --git a/chrome/content/zotero/xpcom/sync/syncEngine.js b/chrome/content/zotero/xpcom/sync/syncEngine.js index a50fb6c99f..620d5b32ea 100644 --- a/chrome/content/zotero/xpcom/sync/syncEngine.js +++ b/chrome/content/zotero/xpcom/sync/syncEngine.js @@ -258,6 +258,8 @@ Zotero.Sync.Data.Engine.prototype._startDownload = Zotero.Promise.coroutine(func stop = !(yield Zotero.Sync.Data.Local.hasObjectsToTryInSyncQueue(this.libraryID)); } if (stop) { + Zotero.debug("Library " + this.libraryID + " hasn't been modified " + + "-- skipping further object downloads"); break; } } @@ -357,8 +359,6 @@ Zotero.Sync.Data.Engine.prototype._downloadSettings = Zotero.Promise.coroutine(f // If library version hasn't changed remotely, the local library is up-to-date and we // can skip all remaining downloads if (results === false) { - Zotero.debug("Library " + this.libraryID + " hasn't been modified " - + "-- skipping further object downloads"); return { result: this.DOWNLOAD_RESULT_LIBRARY_UNMODIFIED, libraryVersion: since diff --git a/chrome/content/zotero/xpcom/sync/syncLocal.js b/chrome/content/zotero/xpcom/sync/syncLocal.js index 0d7494c629..b2060cc2bf 100644 --- a/chrome/content/zotero/xpcom/sync/syncLocal.js +++ b/chrome/content/zotero/xpcom/sync/syncLocal.js @@ -1791,9 +1791,15 @@ Zotero.Sync.Data.Local = { }, - addObjectsToSyncQueue: Zotero.Promise.coroutine(function* (objectType, libraryID, keys) { + /** + * @param {String} objectType + * @param {Integer} libraryID + * @param {String[]} keys + * @param {Boolean} [tryImmediately=false] - Assign lastCheck of 0 so item is retried immediately + */ + addObjectsToSyncQueue: Zotero.Promise.coroutine(function* (objectType, libraryID, keys, tryImmediately) { var syncObjectTypeID = Zotero.Sync.Data.Utilities.getSyncObjectTypeID(objectType); - var now = Zotero.Date.getUnixTimestamp(); + var now = tryImmediately ? 0 : Zotero.Date.getUnixTimestamp(); // Default to first try var keyTries = {}; diff --git a/test/tests/zfsTest.js b/test/tests/zfsTest.js index f6d572868b..6378a31249 100644 --- a/test/tests/zfsTest.js +++ b/test/tests/zfsTest.js @@ -986,7 +986,7 @@ describe("Zotero.Sync.Storage.Mode.ZFS", function () { assert.isFalse(result.remoteChanges); assert.isTrue(result.syncRequired); // Item should be marked for redownloading - var versions = yield Zotero.Sync.Data.Local.getObjectsFromSyncQueue('item', item.libraryID); + var versions = yield Zotero.Sync.Data.Local.getObjectsToTryFromSyncQueue('item', item.libraryID); assert.include(versions, item.key); });