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
Родитель 6965a649ec
Коммит f4e8d5b2f6
2 изменённых файлов: 14 добавлений и 8 удалений

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

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

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

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