Remove Zotero.Items.moveChildItems() transaction requirement exception

Follow-up to 734057ff9b

This was supposed to allow ZotFile to continue to work but 1) it
contained a bug and 2) another transaction messed things up for ZotFile
anyway, so we'll just fix this in jlegewie/zotfile#593.
This commit is contained in:
Dan Stillman 2022-03-22 17:57:50 -04:00
parent 95d8b37f0a
commit 37c48dc3ee
2 changed files with 8 additions and 16 deletions

View file

@ -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);

View file

@ -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();
}
}