Add objects from failed download requests to sync queue
Previously only individual objects from successful requests that couldn't be processed for some reason would be added to the queue. `Sync.APIClient.downloadObjects()` now returns clearer and more consistent results. It now returns an array of promises for objects with a `keys` array of requested keys and either a `json` array of returned API JSON objects or an `error` Error, depending on whether the request succeeded or failed. This makes it easier to detect remotely missing objects and request failures.
This commit is contained in:
parent
86965988b4
commit
644c4e5925
4 changed files with 83 additions and 32 deletions
|
@ -3005,6 +3005,34 @@ describe("Zotero.Sync.Data.Engine", function () {
|
|||
await Zotero.Sync.Data.Local.getDateDeleted('item', libraryID, item.key)
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
it("should add object from failed download request to sync queue", async function () {
|
||||
({ engine, client, caller } = await setup({
|
||||
stopOnError: false
|
||||
}));
|
||||
var libraryID = Zotero.Libraries.userLibraryID;
|
||||
|
||||
var item = await createDataObject('item');
|
||||
var itemKey = item.key;
|
||||
|
||||
var headers = {
|
||||
"Last-Modified-Version": 5
|
||||
};
|
||||
setResponse({
|
||||
method: "GET",
|
||||
url: `users/1/items?itemKey=${itemKey}&includeTrashed=1`,
|
||||
status: 0,
|
||||
headers,
|
||||
body: ""
|
||||
});
|
||||
await engine._downloadObjects('item', [itemKey]);
|
||||
|
||||
assert.sameMembers(
|
||||
await Zotero.Sync.Data.Local.getObjectsFromSyncQueue('item', libraryID),
|
||||
[itemKey]
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue