Bug 1514909 - Update the last sync time from X-L-M instead of X-W-T after a batch upload. r=markh

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Lina Cambridge 2018-12-17 23:34:04 +00:00
Родитель 689eea27da
Коммит d46281dce9
2 изменённых файлов: 8 добавлений и 9 удалений

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

@ -1680,7 +1680,7 @@ SyncEngine.prototype = {
let failed = [];
let successful = [];
let lastSync = await this.getLastSync();
let handleResponse = async (resp, batchOngoing = false) => {
let handleResponse = async (postQueue, resp, batchOngoing) => {
// Note: We don't want to update this.lastSync, or this._modified until
// the batch is complete, however we want to remember success/failure
// indicators for when that happens.
@ -1698,7 +1698,6 @@ SyncEngine.prototype = {
// Nothing to do yet
return;
}
let serverModifiedTime = parseFloat(resp.headers["x-weave-timestamp"]);
if (failed.length && this._log.level <= Log.Level.Debug) {
this._log.debug("Records that will be uploaded again because "
@ -1712,11 +1711,11 @@ SyncEngine.prototype = {
this._modified.delete(id);
}
await this._onRecordsWritten(successful, failed, serverModifiedTime);
await this._onRecordsWritten(successful, failed, postQueue.lastModified);
// Advance lastSync since we've finished the batch.
if (serverModifiedTime > lastSync) {
lastSync = serverModifiedTime;
if (postQueue.lastModified > lastSync) {
lastSync = postQueue.lastModified;
await this.setLastSync(lastSync);
}

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

@ -1065,7 +1065,7 @@ PostQueue.prototype = {
this.log.trace("Server error response during a batch", response);
// not clear what we should do here - we expect the consumer of this to
// abort by throwing in the postCallback below.
await this.postCallback(response, !finalBatchPost);
await this.postCallback(this, response, !finalBatchPost);
return;
}
@ -1073,7 +1073,7 @@ PostQueue.prototype = {
this.log.trace("Committed batch", this.batchID);
this.batchID = undefined; // we are now in "first post for the batch" state.
this.lastModified = response.headers["x-last-modified"];
await this.postCallback(response, false);
await this.postCallback(this, response, false);
return;
}
@ -1083,7 +1083,7 @@ PostQueue.prototype = {
}
this.batchID = null; // no batch semantics are in place.
this.lastModified = response.headers["x-last-modified"];
await this.postCallback(response, false);
await this.postCallback(this, response, false);
return;
}
@ -1110,6 +1110,6 @@ PostQueue.prototype = {
throw new Error(`Invalid client/server batch state - client has ${this.batchID}, server has ${responseBatchID}`);
}
await this.postCallback(response, true);
await this.postCallback(this, response, true);
},
};