From c82baa71a3e890cfc9d3e2eeafd8221946d69a16 Mon Sep 17 00:00:00 2001 From: Thom Chiovoloni Date: Thu, 22 Feb 2018 18:06:45 -0500 Subject: [PATCH] Bug 1435588 - (part 2) Request records oldest first with the bookmarks buffer r=kitcambridge This also adds a check that the sort order is valid to record.js, since I accidentally spelt it "oldest", which didn't work at all. MozReview-Commit-ID: 2edyyjcwGqx --HG-- extra : rebase_source : 051378c4f79f703563a1e14a32a28956f9dcf12b --- services/sync/modules/engines/bookmarks.js | 4 ++++ services/sync/modules/record.js | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/services/sync/modules/engines/bookmarks.js b/services/sync/modules/engines/bookmarks.js index 2c3b16adecdf..04e818ec7a55 100644 --- a/services/sync/modules/engines/bookmarks.js +++ b/services/sync/modules/engines/bookmarks.js @@ -693,6 +693,10 @@ BufferedBookmarksEngine.prototype = { // non-buffered engine is enabled. overrideTelemetryName: "bookmarks-buffered", + // Needed to ensure we don't miss items when resuming a sync that failed or + // aborted early. + _defaultSort: "oldest", + async getLastSync() { let mirror = await this._store.ensureOpenMirror(); return mirror.getCollectionHighWaterMark(); diff --git a/services/sync/modules/record.js b/services/sync/modules/record.js index 78c19dd4b625..70005201f324 100644 --- a/services/sync/modules/record.js +++ b/services/sync/modules/record.js @@ -685,6 +685,10 @@ Collection.prototype = { // index get sort() { return this._sort; }, set sort(value) { + if (value && value != "oldest" && value != "newest" && value != "index") { + throw new TypeError( + `Illegal value for sort: "${value}" (should be "oldest", "newest", or "index").`); + } this._sort = value; this._rebuildURL(); },