mirror of
https://github.com/zotero/zotero.git
synced 2026-09-08 22:21:04 +00:00
Batch Extra field migrations in transactions
This commit is contained in:
parent
add3046e49
commit
899bc9eacf
1 changed files with 19 additions and 11 deletions
|
|
@ -714,19 +714,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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue