diff --git a/chrome/content/zotero/xpcom/attachments.js b/chrome/content/zotero/xpcom/attachments.js index 196cef2b69..7174ea9186 100644 --- a/chrome/content/zotero/xpcom/attachments.js +++ b/chrome/content/zotero/xpcom/attachments.js @@ -2735,7 +2735,9 @@ Zotero.Attachments = new function(){ await newItem.saveTx(); // Move child annotations and embedded-image attachments - await Zotero.Items.moveChildItems(item, newItem); + await Zotero.DB.executeTransaction(async function () { + await Zotero.Items.moveChildItems(item, newItem); + }); // Copy relations pointing to the old item await Zotero.Relations.copyObjectSubjectRelations(item, newItem); diff --git a/chrome/content/zotero/xpcom/data/items.js b/chrome/content/zotero/xpcom/data/items.js index 87feeabe8b..403bf525eb 100644 --- a/chrome/content/zotero/xpcom/data/items.js +++ b/chrome/content/zotero/xpcom/data/items.js @@ -929,24 +929,14 @@ Zotero.Items = function() { * @return {Promise} */ this.moveChildItems = async function (fromItem, toItem, includeTrashed = false) { - //Zotero.DB.requireTransaction(); + Zotero.DB.requireTransaction(); // Annotations on files if (fromItem.isFileAttachment()) { - let fn = async function () { - let annotations = fromItem.getAnnotations(includeTrashed); - for (let annotation of annotations) { - annotation.parentItemID = toItem.id; - await annotation.save(); - } - }; - - if (!Zotero.DB.inTransaction) { - Zotero.logError("moveChildItems() now requires a transaction -- please update your code"); - await Zotero.DB.executeTransaction(fn); - } - else { - await fn(); + let annotations = fromItem.getAnnotations(includeTrashed); + for (let annotation of annotations) { + annotation.parentItemID = toItem.id; + await annotation.save(); } }