commit d38d55e2b4b2a3c3fca01b8f94f7721b406ba0a2
parent 94a0c3ce8c5024ca99972492e0bce65766b15d92
Author: Dan Stillman <dstillman@zotero.org>
Date: Wed, 13 Jun 2018 10:27:26 -0400
Mendeley import: Don't use single transaction
Diffstat:
1 file changed, 40 insertions(+), 41 deletions(-)
diff --git a/chrome/content/zotero/import/mendeley/mendeleyImport.js b/chrome/content/zotero/import/mendeley/mendeleyImport.js
@@ -806,52 +806,51 @@ Zotero_Import_Mendeley.prototype._convertNote = function (note) {
Zotero_Import_Mendeley.prototype._saveItems = async function (libraryID, json) {
var idMap = new Map();
- await Zotero.DB.executeTransaction(async function () {
- var lastExistingParentItem;
- for (let i = 0; i < json.length; i++) {
- let itemJSON = json[i];
-
- // Check if the item has been previously imported
- let item = this._findExistingItem(libraryID, itemJSON, lastExistingParentItem);
- if (item) {
- if (item.isRegularItem()) {
- lastExistingParentItem = item;
-
- // Update any child items to point to the existing item's key instead of the
- // new generated one
- this._updateParentKeys('item', json, i + 1, itemJSON.key, item.key);
-
- // Leave item in any collections it's in
- itemJSON.collections = item.getCollections()
- .map(id => Zotero.Collections.getLibraryAndKeyFromID(id).key)
- .concat(itemJSON.collections || []);
- }
- }
- else {
- lastExistingParentItem = null;
+
+ var lastExistingParentItem;
+ for (let i = 0; i < json.length; i++) {
+ let itemJSON = json[i];
+
+ // Check if the item has been previously imported
+ let item = this._findExistingItem(libraryID, itemJSON, lastExistingParentItem);
+ if (item) {
+ if (item.isRegularItem()) {
+ lastExistingParentItem = item;
- item = new Zotero.Item;
- item.libraryID = libraryID;
- if (itemJSON.key) {
- item.key = itemJSON.key;
- await item.loadPrimaryData();
- }
+ // Update any child items to point to the existing item's key instead of the
+ // new generated one
+ this._updateParentKeys('item', json, i + 1, itemJSON.key, item.key);
+
+ // Leave item in any collections it's in
+ itemJSON.collections = item.getCollections()
+ .map(id => Zotero.Collections.getLibraryAndKeyFromID(id).key)
+ .concat(itemJSON.collections || []);
}
+ }
+ else {
+ lastExistingParentItem = null;
- // Remove external id before save
- let toSave = Object.assign({}, itemJSON);
- delete toSave.documentID;
-
- item.fromJSON(toSave);
- await item.save({
- skipSelect: true,
- skipDateModifiedUpdate: true
- });
- if (itemJSON.documentID) {
- idMap.set(itemJSON.documentID, item.id);
+ item = new Zotero.Item;
+ item.libraryID = libraryID;
+ if (itemJSON.key) {
+ item.key = itemJSON.key;
+ await item.loadPrimaryData();
}
}
- }.bind(this));
+
+ // Remove external id before save
+ let toSave = Object.assign({}, itemJSON);
+ delete toSave.documentID;
+
+ item.fromJSON(toSave);
+ await item.saveTx({
+ skipSelect: true,
+ skipDateModifiedUpdate: true
+ });
+ if (itemJSON.documentID) {
+ idMap.set(itemJSON.documentID, item.id);
+ }
+ }
return idMap;
};