Copy items across libraries in batches of 100

This will hopefully fix failures when copying huge numbers of items.
This commit is contained in:
Dan Stillman 2018-09-14 04:10:14 -04:00
parent 0cb683ab18
commit f4ac511b50

View file

@ -2169,16 +2169,22 @@ Zotero.CollectionTreeView.prototype.drop = Zotero.Promise.coroutine(function* (r
if (!sameLibrary) { if (!sameLibrary) {
let toReconcile = []; let toReconcile = [];
yield Zotero.DB.executeTransaction(function* () { yield Zotero.Utilities.Internal.forEachChunkAsync(
for (let item of newItems) { newItems,
var id = yield copyItem(item, targetLibraryID, copyOptions) 100,
// Standalone attachments might not get copied function (chunk) {
if (!id) { return Zotero.DB.executeTransaction(async function () {
continue; for (let item of chunk) {
} var id = await copyItem(item, targetLibraryID, copyOptions)
newIDs.push(id); // Standalone attachments might not get copied
if (!id) {
continue;
}
newIDs.push(id);
}
});
} }
}); );
if (toReconcile.length) { if (toReconcile.length) {
let sourceName = Zotero.Libraries.getName(items[0].libraryID); let sourceName = Zotero.Libraries.getName(items[0].libraryID);