Use coroutine() in Zotero.Sync.Data.Engine::_downloadObjects()

This commit is contained in:
Dan Stillman 2017-05-05 00:29:12 -04:00
parent 7a839e19a6
commit ad9c2ed36c

View File

@ -501,7 +501,7 @@ Zotero.Sync.Data.Engine.prototype._downloadObjects = Zotero.Promise.coroutine(fu
// Process batches when they're available, one at a time
yield Zotero.Promise.map(
json,
function (batch) {
Zotero.Promise.coroutine(function* (batch) {
this._failedCheck();
Zotero.debug(`Processing batch of downloaded ${objectTypePlural} in `
@ -520,7 +520,7 @@ Zotero.Sync.Data.Engine.prototype._downloadObjects = Zotero.Promise.coroutine(fu
});
// Process objects
return Zotero.Sync.Data.Local.processObjectsFromJSON(
let results = yield Zotero.Sync.Data.Local.processObjectsFromJSON(
objectType,
this.libraryID,
batch,
@ -546,8 +546,8 @@ Zotero.Sync.Data.Engine.prototype._downloadObjects = Zotero.Promise.coroutine(fu
return Math.min(size, batch.length);
}
})
)
.then(function (results) {
);
num += results.length;
let processedKeys = [];
let conflictResults = [];
@ -566,8 +566,7 @@ Zotero.Sync.Data.Engine.prototype._downloadObjects = Zotero.Promise.coroutine(fu
});
keys = Zotero.Utilities.arrayDiff(keys, processedKeys);
conflicts.push(...conflictResults);
}.bind(this));
}.bind(this),
}.bind(this)),
{
concurrency: 1
}