Fix unnecessary sync looping after downloading items
An extra sync loop would be performed for every object downloaded, so a
download to an empty database could result in a huge number of
unnecessary loops. This was a regression from 52932b6eb
, which started
queuing auto-syncs while a sync was in progress. The fix here is to skip
auto-sync for all objects saved from a sync download.
There are two new mechanisms involved:
- Event-level notifier options that get passed to passed to notify() at
the top level of extraData rather than being included with every
object (e.g., because `skipAutoSync` should apply to an entire save
transaction)
- The ability to pass event-level notifier options when initializing
a Zotero.Notifier.Queue, such as the one used for sync downloads
This commit is contained in:
parent
5b0f02a12b
commit
7ace5ea29e
6 changed files with 113 additions and 12 deletions
|
@ -515,6 +515,35 @@ describe("Zotero.Sync.Data.Local", function() {
|
|||
});
|
||||
})
|
||||
|
||||
it("shouldn't trigger an auto-sync", async function () {
|
||||
var libraryID = Zotero.Libraries.userLibraryID;
|
||||
|
||||
var item = createUnsavedDataObject('item');
|
||||
let data = item.toJSON();
|
||||
data.key = Zotero.DataObjectUtilities.generateKey();
|
||||
data.version = 10;
|
||||
let json = {
|
||||
key: data.key,
|
||||
version: 10,
|
||||
data
|
||||
};
|
||||
|
||||
// Make sure the pref in question is still disabled by default during tests
|
||||
assert.isFalse(Zotero.Prefs.get('sync.autoSync'));
|
||||
Zotero.Prefs.set('sync.autoSync', true);
|
||||
var stub = sinon.stub(Zotero.Sync.Runner, 'setSyncTimeout');
|
||||
|
||||
await Zotero.Sync.Data.Local.processObjectsFromJSON(
|
||||
'item', libraryID, [json], { stopOnError: true }
|
||||
);
|
||||
|
||||
// setSyncTimeout() shouldn't have been called at all
|
||||
assert.isFalse(stub.called);
|
||||
|
||||
stub.restore();
|
||||
Zotero.Prefs.set('sync.autoSync', false);
|
||||
});
|
||||
|
||||
it("should update local version number and mark as synced if remote version is identical", function* () {
|
||||
var libraryID = Zotero.Libraries.userLibraryID;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue