From faf8f2510ecf38d24580d74771542ef4506375e9 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Wed, 7 Jan 2026 11:05:57 -0500 Subject: [PATCH] Batch Extra field migrations in transactions --- chrome/content/zotero/xpcom/schema.js | 30 +++++++++++++++++---------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/chrome/content/zotero/xpcom/schema.js b/chrome/content/zotero/xpcom/schema.js index 3b8f43ab4a..ecc87d9ce3 100644 --- a/chrome/content/zotero/xpcom/schema.js +++ b/chrome/content/zotero/xpcom/schema.js @@ -715,19 +715,27 @@ Zotero.Schema = new function () { let notifierQueue = new Zotero.Notifier.Queue; try { - for (let item of items) { - let changed = item.migrateExtraFields(); - if (changed) { - await item.saveTx({ - skipDateModifiedUpdate: true, - skipSelect: true, - notifierQueue + await Zotero.Utilities.Internal.forEachChunkAsync( + items, + 100, + async function (chunk) { + await Zotero.DB.executeTransaction(async function () { + for (let item of chunk) { + let changed = item.migrateExtraFields(); + if (changed) { + await item.save({ + skipDateModifiedUpdate: true, + skipSelect: true, + notifierQueue + }); + } + if (onProgress) { + onProgress({ progress: ++progress, progressMax }); + } + } }); } - if (onProgress) { - onProgress({ progress: ++progress, progressMax }); - } - } + ); } finally { await Zotero.Notifier.commit(notifierQueue);