Skip items in save session that no longer exist

Ideally I guess the entry would be removed from the save popup in the
connector and a second button click would do a fresh save rather than
reopening the popup, but for now just avoid an error.

Addresses zotero/zotero-connectors#220
This commit is contained in:
Dan Stillman 2018-03-29 07:40:31 -04:00
parent a4aabd9f3e
commit 9b9773db16

View file

@ -200,6 +200,10 @@ Zotero.Server.Connector.SaveSession.prototype._updateObjects = async function (o
// a child item (e.g., from Retrieve Metadata for PDF)
if (objectType == 'item') {
let item = object.isTopLevelItem() ? object : object.parentItem;
if (!Zotero.Items.exists(item.id)) {
Zotero.debug(`Item ${item.id} in save session no longer exists`);
continue;
}
// Keep automatic tags
let originalTags = item.getTags().filter(tag => tag.type == 1);
item.setTags(originalTags.concat(tags));