some more ClientData fixes; *do* wipe the server when there is no version file; upload the version file when needed; refresh ClientData on login

This commit is contained in:
Dan Mills 2008-07-29 18:34:10 -07:00
parent 6965a649ec
commit f4e8d5b2f6
2 changed files with 14 additions and 8 deletions

View File

@ -109,16 +109,16 @@ ClientDataSvc.prototype = {
if(!ret)
throw "Could not create meta information directory";
try {
yield this._remote.get(self.cb);
} catch(e if e.status == 404) {
try { yield this._remote.get(self.cb); }
catch (e if e.status == 404) {
this._remote.data = {};
}
this._remote.data[this.GUID] = this._wrap();
yield this._remote.put(self.cb);
this._log.debug("Successfully downloaded clients file from server");
},
refresh: function ClientData_refresh() {
refresh: function ClientData_refresh(onComplete) {
this._refresh.async(this, onComplete);
}
};

View File

@ -339,10 +339,14 @@ WeaveSvc.prototype = {
_versionCheck: function WeaveSvc__versionCheck() {
let self = yield;
DAV.GET("meta/version", self.cb);
let ret = yield;
let ret = yield DAV.GET("meta/version", self.cb);
if (Utils.checkStatus(ret.status)) {
if (ret.status == 404) {
this._log.info("Could not get version file. Wiping server data.");
yield this._serverWipe.async(this, self.cb);
yield this._uploadVersion.async(this, self.cb);
} else if (!Utils.checkStatus(ret.status)) {
this._log.debug("Could not get version file from server");
self.done(false);
return;
@ -351,7 +355,6 @@ WeaveSvc.prototype = {
this._log.info("Server version too low. Wiping server data.");
yield this._serverWipe.async(this, self.cb);
yield this._uploadVersion.async(this, self.cb);
yield ClientData.upload
} else if (ret.responseText > STORAGE_FORMAT_VERSION) {
// XXX should we do something here?
@ -686,6 +689,9 @@ WeaveSvc.prototype = {
// wipe the server if it has any old cruft
yield this._versionCheck.async(this, self.cb);
// get info on the clients that are syncing with this store
yield ClientData.refresh(self.cb);
// cache keys, create public/private keypair if it doesn't exist
this._log.debug("Caching keys");
let privkeyResp = yield DAV.GET("private/privkey", self.cb);