Bug 1620185 - Replace pullMetadata() with low level code r=glasserc

Differential Revision: https://phabricator.services.mozilla.com/D66411

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Mathieu Leplatre 2020-03-17 20:19:23 +00:00
Родитель 5b64d20ae2
Коммит 6d01f4e707
1 изменённых файлов: 13 добавлений и 3 удалений

Просмотреть файл

@ -735,7 +735,8 @@ class RemoteSettingsClient extends EventEmitter {
async _importChanges(
kintoCollection,
collectionLastModified,
expectedTimestamp
expectedTimestamp,
{ headers } = {}
) {
const syncResult = {
add(type, entries) {
@ -747,14 +748,23 @@ class RemoteSettingsClient extends EventEmitter {
updated: [],
deleted: [],
};
const httpClient = this.httpClient();
// Fetch collection metadata.
const query = expectedTimestamp
? { query: { _expected: expectedTimestamp } }
: undefined;
const metadata = await httpClient.getData({
...query,
headers,
});
await kintoCollection.db.saveMetadata(metadata);
const options = {
lastModified: collectionLastModified,
strategy: Kinto.syncStrategy.PULL_ONLY,
expectedTimestamp,
};
const httpClient = this.httpClient();
await kintoCollection.pullMetadata(httpClient, options);
// Fetch last changes from the server.
await kintoCollection.pullChanges(httpClient, syncResult, options);
const { lastModified } = syncResult;