Use coroutine() in Zotero.Sync.Data.Engine::_downloadObjects()
This commit is contained in:
parent
7a839e19a6
commit
ad9c2ed36c
|
@ -501,7 +501,7 @@ Zotero.Sync.Data.Engine.prototype._downloadObjects = Zotero.Promise.coroutine(fu
|
||||||
// Process batches when they're available, one at a time
|
// Process batches when they're available, one at a time
|
||||||
yield Zotero.Promise.map(
|
yield Zotero.Promise.map(
|
||||||
json,
|
json,
|
||||||
function (batch) {
|
Zotero.Promise.coroutine(function* (batch) {
|
||||||
this._failedCheck();
|
this._failedCheck();
|
||||||
|
|
||||||
Zotero.debug(`Processing batch of downloaded ${objectTypePlural} in `
|
Zotero.debug(`Processing batch of downloaded ${objectTypePlural} in `
|
||||||
|
@ -520,7 +520,7 @@ Zotero.Sync.Data.Engine.prototype._downloadObjects = Zotero.Promise.coroutine(fu
|
||||||
});
|
});
|
||||||
|
|
||||||
// Process objects
|
// Process objects
|
||||||
return Zotero.Sync.Data.Local.processObjectsFromJSON(
|
let results = yield Zotero.Sync.Data.Local.processObjectsFromJSON(
|
||||||
objectType,
|
objectType,
|
||||||
this.libraryID,
|
this.libraryID,
|
||||||
batch,
|
batch,
|
||||||
|
@ -546,28 +546,27 @@ Zotero.Sync.Data.Engine.prototype._downloadObjects = Zotero.Promise.coroutine(fu
|
||||||
return Math.min(size, batch.length);
|
return Math.min(size, batch.length);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
)
|
);
|
||||||
.then(function (results) {
|
|
||||||
num += results.length;
|
num += results.length;
|
||||||
let processedKeys = [];
|
let processedKeys = [];
|
||||||
let conflictResults = [];
|
let conflictResults = [];
|
||||||
results.forEach(x => {
|
results.forEach(x => {
|
||||||
// If data was processed, remove JSON
|
// If data was processed, remove JSON
|
||||||
if (x.processed) {
|
if (x.processed) {
|
||||||
delete objectData[x.key];
|
delete objectData[x.key];
|
||||||
}
|
}
|
||||||
// If object shouldn't be retried, mark as processed
|
// If object shouldn't be retried, mark as processed
|
||||||
if (x.processed || !x.retry) {
|
if (x.processed || !x.retry) {
|
||||||
processedKeys.push(x.key);
|
processedKeys.push(x.key);
|
||||||
}
|
}
|
||||||
if (x.conflict) {
|
if (x.conflict) {
|
||||||
conflictResults.push(x);
|
conflictResults.push(x);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
keys = Zotero.Utilities.arrayDiff(keys, processedKeys);
|
keys = Zotero.Utilities.arrayDiff(keys, processedKeys);
|
||||||
conflicts.push(...conflictResults);
|
conflicts.push(...conflictResults);
|
||||||
}.bind(this));
|
}.bind(this)),
|
||||||
}.bind(this),
|
|
||||||
{
|
{
|
||||||
concurrency: 1
|
concurrency: 1
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user