зеркало из https://github.com/mozilla/gecko-dev.git
Bug 504788 - Handle different weave versions by wiping, upgrading, updating. r=thunder
Store the most newest Weave version on the server and update it if necessary on each remoteSetup. Make a concept of a compatible version where this version of Weave can read but might change records with its full sync. --HG-- extra : rebase_source : c11cada1e3ba07e00113fca439610d0b6fd78190
This commit is contained in:
Родитель
54314c829e
Коммит
da26bc9eee
|
@ -34,7 +34,7 @@
|
||||||
*
|
*
|
||||||
* ***** END LICENSE BLOCK ***** */
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
const EXPORTED_SYMBOLS = ["WEAVE_VERSION", "STORAGE_VERSION",
|
const EXPORTED_SYMBOLS = ["WEAVE_VERSION", "COMPATIBLE_VERSION",
|
||||||
'PREFS_BRANCH',
|
'PREFS_BRANCH',
|
||||||
'MODE_RDONLY', 'MODE_WRONLY',
|
'MODE_RDONLY', 'MODE_WRONLY',
|
||||||
'MODE_CREATE', 'MODE_APPEND', 'MODE_TRUNCATE',
|
'MODE_CREATE', 'MODE_APPEND', 'MODE_TRUNCATE',
|
||||||
|
@ -59,7 +59,7 @@ const WEAVE_VERSION = "@weave_version@";
|
||||||
// last client version's server storage this version supports
|
// last client version's server storage this version supports
|
||||||
// e.g. if set to the current version, this client will wipe the server
|
// e.g. if set to the current version, this client will wipe the server
|
||||||
// data stored by any older client
|
// data stored by any older client
|
||||||
const STORAGE_VERSION = "@storage_version@";
|
const COMPATIBLE_VERSION = "@compatible_version@";
|
||||||
|
|
||||||
const PREFS_BRANCH = "extensions.weave.";
|
const PREFS_BRANCH = "extensions.weave.";
|
||||||
|
|
||||||
|
|
|
@ -682,11 +682,11 @@ WeaveSvc.prototype = {
|
||||||
let remoteVersion = (meta && meta.payload.storageVersion)?
|
let remoteVersion = (meta && meta.payload.storageVersion)?
|
||||||
meta.payload.storageVersion : "";
|
meta.payload.storageVersion : "";
|
||||||
|
|
||||||
this._log.debug("Local storage version is " + STORAGE_VERSION);
|
this._log.debug(["Weave Version:", WEAVE_VERSION, "Compatible:",
|
||||||
this._log.debug("Remote storage version is " + remoteVersion);
|
COMPATIBLE_VERSION, "Remote:", remoteVersion].join(" "));
|
||||||
|
|
||||||
if (!meta || !meta.payload.storageVersion || !meta.payload.syncID ||
|
if (!meta || !meta.payload.storageVersion || !meta.payload.syncID ||
|
||||||
Svc.Version.compare(STORAGE_VERSION, remoteVersion) > 0) {
|
Svc.Version.compare(COMPATIBLE_VERSION, remoteVersion) > 0) {
|
||||||
|
|
||||||
// abort the server wipe if the GET status was anything other than 404 or 200
|
// abort the server wipe if the GET status was anything other than 404 or 200
|
||||||
let status = Records.lastResource.lastChannel.responseStatus;
|
let status = Records.lastResource.lastChannel.responseStatus;
|
||||||
|
@ -701,8 +701,8 @@ WeaveSvc.prototype = {
|
||||||
this._log.info("No metadata record, server wipe needed");
|
this._log.info("No metadata record, server wipe needed");
|
||||||
if (meta && !meta.payload.syncID)
|
if (meta && !meta.payload.syncID)
|
||||||
this._log.warn("No sync id, server wipe needed");
|
this._log.warn("No sync id, server wipe needed");
|
||||||
if (Svc.Version.compare(STORAGE_VERSION, remoteVersion) > 0)
|
if (Svc.Version.compare(COMPATIBLE_VERSION, remoteVersion) > 0)
|
||||||
this._log.info("Server storage version no longer supported, server wipe needed");
|
this._log.info("Server data is older than what Weave supports, server wipe needed");
|
||||||
|
|
||||||
if (!this._keyGenEnabled) {
|
if (!this._keyGenEnabled) {
|
||||||
this._log.info("...and key generation is disabled. Not wiping. " +
|
this._log.info("...and key generation is disabled. Not wiping. " +
|
||||||
|
@ -719,9 +719,9 @@ WeaveSvc.prototype = {
|
||||||
"consistency.");
|
"consistency.");
|
||||||
else // 200
|
else // 200
|
||||||
this._log.info("Server data wiped to ensure consistency after client " +
|
this._log.info("Server data wiped to ensure consistency after client " +
|
||||||
"upgrade (" + remoteVersion + " -> " + STORAGE_VERSION + ")");
|
"upgrade (" + remoteVersion + " -> " + WEAVE_VERSION + ")");
|
||||||
|
|
||||||
} else if (Svc.Version.compare(remoteVersion, STORAGE_VERSION) > 0) {
|
} else if (Svc.Version.compare(remoteVersion, WEAVE_VERSION) > 0) {
|
||||||
this._setSyncFailure(VERSION_OUT_OF_DATE);
|
this._setSyncFailure(VERSION_OUT_OF_DATE);
|
||||||
this._log.warn("Server data is of a newer Weave version, this client " +
|
this._log.warn("Server data is of a newer Weave version, this client " +
|
||||||
"needs to be upgraded. Aborting sync.");
|
"needs to be upgraded. Aborting sync.");
|
||||||
|
@ -734,7 +734,11 @@ WeaveSvc.prototype = {
|
||||||
this._log.info("Reset client because of syncID mismatch.");
|
this._log.info("Reset client because of syncID mismatch.");
|
||||||
Clients.syncID = meta.payload.syncID;
|
Clients.syncID = meta.payload.syncID;
|
||||||
this._log.info("Reset the client after a server/client sync ID mismatch");
|
this._log.info("Reset the client after a server/client sync ID mismatch");
|
||||||
|
this._updateRemoteVersion(meta);
|
||||||
}
|
}
|
||||||
|
// We didn't wipe the server and we're not out of date, so update remote
|
||||||
|
else
|
||||||
|
this._updateRemoteVersion(meta);
|
||||||
|
|
||||||
let needKeys = true;
|
let needKeys = true;
|
||||||
let pubkey = PubKeys.getDefaultKey();
|
let pubkey = PubKeys.getDefaultKey();
|
||||||
|
@ -1001,9 +1005,17 @@ WeaveSvc.prototype = {
|
||||||
|
|
||||||
this._log.debug("Uploading new metadata record");
|
this._log.debug("Uploading new metadata record");
|
||||||
meta = new WBORecord(this.clusterURL + this.username + "/meta/global");
|
meta = new WBORecord(this.clusterURL + this.username + "/meta/global");
|
||||||
this._log.debug("Setting meta payload storage version to " + STORAGE_VERSION);
|
|
||||||
meta.payload.storageVersion = STORAGE_VERSION;
|
|
||||||
meta.payload.syncID = Clients.syncID;
|
meta.payload.syncID = Clients.syncID;
|
||||||
|
this._updateRemoteVersion(meta);
|
||||||
|
},
|
||||||
|
|
||||||
|
_updateRemoteVersion: function WeaveSvc__updateRemoteVersion(meta) {
|
||||||
|
// Don't update if the remote version is already newer
|
||||||
|
if (Svc.Version.compare(meta.payload.storageVersion, WEAVE_VERSION) >= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
this._log.debug("Setting meta payload storage version to " + WEAVE_VERSION);
|
||||||
|
meta.payload.storageVersion = WEAVE_VERSION;
|
||||||
let res = new Resource(meta.uri);
|
let res = new Resource(meta.uri);
|
||||||
res.put(meta.serialize());
|
res.put(meta.serialize());
|
||||||
},
|
},
|
||||||
|
|
Загрузка…
Ссылка в новой задаче