зеркало из https://github.com/mozilla/gecko-dev.git
Bug 615926: attempt to avoid screwing up meta.
This commit is contained in:
Родитель
901929364b
Коммит
c2ac353231
|
@ -1062,6 +1062,27 @@ WeaveSvc.prototype = {
|
|||
|
||||
this._log.debug("Fetching global metadata record");
|
||||
let meta = Records.get(this.metaURL);
|
||||
|
||||
// Checking modified time of the meta record.
|
||||
if (infoResponse &&
|
||||
(infoResponse.obj.meta != this.metaModified) &&
|
||||
!meta.isNew) {
|
||||
|
||||
// Delete the cached meta record...
|
||||
this._log.debug("Clearing cached meta record. metaModified is " +
|
||||
JSON.stringify(this.metaModified) + ", setting to " +
|
||||
JSON.stringify(info.obj.meta));
|
||||
Records.del(this.metaURL);
|
||||
|
||||
// ... fetch the current record from the server, and COPY THE FLAGS.
|
||||
let newMeta = Records.get(this.metaURL);
|
||||
newMeta.isNew = meta.isNew;
|
||||
newMeta.changed = meta.changed;
|
||||
|
||||
// Switch in the new meta object and record the new time.
|
||||
meta = newMeta;
|
||||
this.metaModified = info.obj.meta;
|
||||
}
|
||||
|
||||
let remoteVersion = (meta && meta.payload.storageVersion)?
|
||||
meta.payload.storageVersion : "";
|
||||
|
@ -1073,6 +1094,8 @@ WeaveSvc.prototype = {
|
|||
// we need to convert it to a number as older clients used it as a string.
|
||||
if (!meta || !meta.payload.storageVersion || !meta.payload.syncID ||
|
||||
STORAGE_VERSION > parseFloat(remoteVersion)) {
|
||||
|
||||
this._log.info("One of: no meta, no meta storageVersion, or no meta syncID. Fresh start needed.");
|
||||
|
||||
// abort the server wipe if the GET status was anything other than 404 or 200
|
||||
let status = Records.response.status;
|
||||
|
@ -1108,6 +1131,8 @@ WeaveSvc.prototype = {
|
|||
return false;
|
||||
}
|
||||
else if (meta.payload.syncID != this.syncID) {
|
||||
|
||||
this._log.info("Sync IDs differ. Local is " + this.syncID + ", remote is " + meta.payload.syncID);
|
||||
this.resetClient();
|
||||
this.syncID = meta.payload.syncID;
|
||||
this._log.debug("Clear cached values and take syncId: " + this.syncID);
|
||||
|
@ -1408,16 +1433,6 @@ WeaveSvc.prototype = {
|
|||
for each (let engine in [Clients].concat(Engines.getAll()))
|
||||
engine.lastModified = info.obj[engine.name] || 0;
|
||||
|
||||
// If the modified time of the meta record ever changes, clear the cache.
|
||||
// ... unless meta is marked as new.
|
||||
if ((info.obj.meta != this.metaModified) && !Records.get(this.metaURL).isNew) {
|
||||
this._log.debug("Clearing cached meta record. metaModified is " +
|
||||
JSON.stringify(this.metaModified) + ", setting to " +
|
||||
JSON.stringify(info.obj.meta));
|
||||
Records.del(this.metaURL);
|
||||
this.metaModified = info.obj.meta;
|
||||
}
|
||||
|
||||
if (!(this._remoteSetup(info)))
|
||||
throw "aborting sync, remote setup failed";
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче