Further fixing of "Too many sync requests" error

Follow-up to 804a898c98

Addresses #1788
This commit is contained in:
Dan Stillman 2020-02-16 18:02:37 -05:00
parent 8f1acad2d8
commit b41734924d
4 changed files with 13 additions and 7 deletions

View file

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

View file

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

View file

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

View file

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