diff --git a/chrome/content/zotfile/zotfile.js b/chrome/content/zotfile/zotfile.js index 9217af54..498417bb 100644 --- a/chrome/content/zotfile/zotfile.js +++ b/chrome/content/zotfile/zotfile.js @@ -911,18 +911,21 @@ Zotero.ZotFile = new function() { win.ZoteroPane.itemsView.selectItems(selection); } // update links to attachment file in notes - Zotero.Items.get(item.getNotes()).forEach(note => { + var notes = Zotero.Items.get(item.getNotes()); + for (let note of notes) { var content = note.getNote(); content = content.replace(new RegExp('open-pdf/([\\w\\W\\d]{1,10})_' + att.key, 'g'), 'open-pdf/$1_' + attNew.key); note.setNote(content); - note.saveTx(); - }); + yield note.saveTx(); + } // transfer various attachment data // // should stay in sync with Zotero.Attachments.convertLinkedFileToStoredFile() if (this.isZotero6OrLater) { // move child annotations and embedded-image attachments - yield Zotero.Items.moveChildItems(att, attNew); + yield Zotero.DB.executeTransaction(async function () { + await Zotero.Items.moveChildItems(att, attNew); + }); // copy relations pointing to the old item yield Zotero.Relations.copyObjectSubjectRelations(att, attNew); // transfer full-text item index @@ -975,18 +978,21 @@ Zotero.ZotFile = new function() { win.ZoteroPane.itemsView.selectItems(selection); } // update links to attachment file in notes - Zotero.Items.get(item.getNotes()).forEach(note => { + var notes = Zotero.Items.get(item.getNotes()); + for (let note of notes) { var content = note.getNote(); content = content.replace(new RegExp('open-pdf/([\\w\\W\\d]{1,10})_' + att.key, 'g'), 'open-pdf/$1_' + attNew.key); note.setNote(content); - note.saveTx(); - }); + yield note.saveTx(); + } // transfer various attachment data // // should stay in sync with Zotero.Attachments.convertLinkedFileToStoredFile() if (this.isZotero6OrLater) { // move child annotations and embedded-image attachments - yield Zotero.Items.moveChildItems(att, attNew); + yield Zotero.DB.executeTransaction(async function () { + await Zotero.Items.moveChildItems(att, attNew); + }); // copy relations pointing to the old item yield Zotero.Relations.copyObjectSubjectRelations(att, attNew); // transfer full-text item index