Bug 1414438 - Use `getBatched` instead of `get` to backfill records r=kitcambridge
authortfe <tfeserver@gmail.com>
Wed, 08 Nov 2017 09:05:11 +0100
changeset 695360 e794bc60c010ab925f85ccec7a6ce19543cfa482
parent 695359 27ca9370036f9f0a39203073201e13918064cf75
child 695361 77d2425c4b40307d8a34fa8f6d52a8e16971e71f
push id88406
push userbmo:mh+mozilla@glandium.org
push dateThu, 09 Nov 2017 05:17:33 +0000
reviewerskitcambridge
bugs1414438
milestone58.0a1
Bug 1414438 - Use `getBatched` instead of `get` to backfill records r=kitcambridge MozReview-Commit-ID: LLTg0ae5BbW *** Bug 1414438 - Use `getBatched` instead of `get` in sync
services/sync/modules/engines.js
--- a/services/sync/modules/engines.js
+++ b/services/sync/modules/engines.js
@@ -1194,35 +1194,33 @@ SyncEngine.prototype = {
     // every subsequent sync just adds noise.
     this.previousFailed = failedInCurrentSync;
 
     let backfilledItems = this.itemSource();
 
     backfilledItems.sort = "newest";
     backfilledItems.full = true;
 
-    // `get` includes the list of IDs as a query parameter, so we need to fetch
+    // `getBatched` includes the list of IDs as a query parameter, so we need to fetch
     // records in chunks to avoid exceeding URI length limits.
     for (let ids of PlacesSyncUtils.chunkArray(idsToBackfill, this.guidFetchBatchSize)) {
       backfilledItems.ids = ids;
 
-      let resp = await backfilledItems.get();
-      if (!resp.success) {
-        resp.failureCode = ENGINE_DOWNLOAD_FAIL;
-        throw resp;
+      let {response, records} = await backfilledItems.getBatched(this.downloadBatchSize);
+      if (!response.success) {
+        response.failureCode = ENGINE_DOWNLOAD_FAIL;
+        throw response;
       }
 
       let maybeYield = Async.jankYielder();
       let backfilledRecordsToApply = [];
       let failedInBackfill = [];
 
-      for (let json of resp.obj) {
+      for (let record of records) {
         await maybeYield();
-        let record = new this._recordObj();
-        record.deserialize(json);
 
         let { shouldApply, error } = await this._maybeReconcile(record);
         if (error) {
           failedInBackfill.push(record.id);
           count.failed++;
           continue;
         }
         if (!shouldApply) {