Batch object deletions during syncing
This commit is contained in:
parent
fd7c2a6f6f
commit
701a46ba84
|
@ -765,6 +765,8 @@ Zotero.Sync.Data.Engine.prototype._restoreRestoredCollectionItems = async functi
|
||||||
* @return {Promise<Integer>} - A download result code (this.DOWNLOAD_RESULT_*)
|
* @return {Promise<Integer>} - A download result code (this.DOWNLOAD_RESULT_*)
|
||||||
*/
|
*/
|
||||||
Zotero.Sync.Data.Engine.prototype._downloadDeletions = Zotero.Promise.coroutine(function* (since, newLibraryVersion) {
|
Zotero.Sync.Data.Engine.prototype._downloadDeletions = Zotero.Promise.coroutine(function* (since, newLibraryVersion) {
|
||||||
|
const batchSize = 50;
|
||||||
|
|
||||||
let results = yield this.apiClient.getDeleted(
|
let results = yield this.apiClient.getDeleted(
|
||||||
this.library.libraryType,
|
this.library.libraryType,
|
||||||
this.libraryTypeID,
|
this.libraryTypeID,
|
||||||
|
@ -856,10 +858,9 @@ Zotero.Sync.Data.Engine.prototype._downloadDeletions = Zotero.Promise.coroutine(
|
||||||
Zotero.debug("Cancelling sync");
|
Zotero.debug("Cancelling sync");
|
||||||
throw new Zotero.Sync.UserCancelledException();
|
throw new Zotero.Sync.UserCancelledException();
|
||||||
}
|
}
|
||||||
let concurrentObjects = 50;
|
|
||||||
yield Zotero.Utilities.Internal.forEachChunkAsync(
|
yield Zotero.Utilities.Internal.forEachChunkAsync(
|
||||||
mergeData,
|
mergeData,
|
||||||
concurrentObjects,
|
batchSize,
|
||||||
function (chunk) {
|
function (chunk) {
|
||||||
return Zotero.DB.executeTransaction(function* () {
|
return Zotero.DB.executeTransaction(function* () {
|
||||||
for (let json of chunk) {
|
for (let json of chunk) {
|
||||||
|
@ -882,14 +883,20 @@ Zotero.Sync.Data.Engine.prototype._downloadDeletions = Zotero.Promise.coroutine(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (toDelete.length) {
|
if (toDelete.length) {
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.Utilities.Internal.forEachChunkAsync(
|
||||||
for (let obj of toDelete) {
|
toDelete,
|
||||||
yield obj.erase({
|
batchSize,
|
||||||
skipEditCheck: true,
|
function (chunk) {
|
||||||
skipDeleteLog: true
|
return Zotero.DB.executeTransaction(function* () {
|
||||||
|
for (let obj of chunk) {
|
||||||
|
yield obj.erase({
|
||||||
|
skipEditCheck: true,
|
||||||
|
skipDeleteLog: true
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user