Fix a /saveItems session management race condition bug

This commit is contained in:
Adomas Venčkauskas 2018-12-14 14:11:42 +02:00
parent a24cada451
commit 90a70f7c31
2 changed files with 5 additions and 4 deletions

View file

@ -742,9 +742,10 @@ Zotero.Server.Connector.SaveItems.prototype = {
session, session,
targetID, targetID,
requestData, requestData,
function (topLevelItems) { function (jsonItems, items) {
session.addItems(items);
// Only return the properties the connector needs // Only return the properties the connector needs
topLevelItems = topLevelItems.map((item) => { jsonItems = jsonItems.map((item) => {
let o = { let o = {
id: item.id, id: item.id,
title: item.title, title: item.title,
@ -764,7 +765,7 @@ Zotero.Server.Connector.SaveItems.prototype = {
}; };
return o; return o;
}); });
resolve([201, "application/json", JSON.stringify({items: topLevelItems})]); resolve([201, "application/json", JSON.stringify({items: jsonItems})]);
} }
) )
// Add items to session once all attachments have been saved // Add items to session once all attachments have been saved

View file

@ -179,7 +179,7 @@ Zotero.Translate.ItemSaver.prototype = {
}.bind(this)); }.bind(this));
if (itemsDoneCallback) { if (itemsDoneCallback) {
itemsDoneCallback(items.map(item => jsonByItem.get(item))); itemsDoneCallback(items.map(item => jsonByItem.get(item)), items);
} }
// Save standalone attachments // Save standalone attachments