From a6a7141691283c7b2d86435b79dabfe34df11a37 Mon Sep 17 00:00:00 2001 From: Dan Mills Date: Tue, 17 Feb 2009 13:20:02 -0800 Subject: [PATCH 1/2] add a method for resetting the engine's lastSync pref --- services/sync/modules/engines.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/services/sync/modules/engines.js b/services/sync/modules/engines.js index c050cce4b71..01f6453eadd 100644 --- a/services/sync/modules/engines.js +++ b/services/sync/modules/engines.js @@ -199,14 +199,15 @@ SyncEngine.prototype = { }, get lastSync() { - try { - return Utils.prefs.getCharPref(this.name + ".lastSync"); - } catch (e) { - return 0; - } + return Svc.Prefs.get(this.name + ".lastSync", 0); }, set lastSync(value) { - Utils.prefs.setCharPref(this.name + ".lastSync", value); + Svc.Prefs.set(this.name + ".lastSync", value); + }, + resetLastSync: function SyncEngine_resetLastSync() { + this._log.debug("Resetting " + this.name + " last sync time"); + Svc.Prefs.reset(this.name + ".lastSync"); + Svc.Prefs.set(this.name + ".lastSync", 0); }, // Create a new record by querying the store, and add the engine metadata From d5fc9b632c06cdf86ccfc82a8284bf5c29b32dbb Mon Sep 17 00:00:00 2001 From: Dan Mills Date: Tue, 17 Feb 2009 13:21:14 -0800 Subject: [PATCH 2/2] reset engine lastSync prefs when wiping the server --- services/sync/modules/service.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/services/sync/modules/service.js b/services/sync/modules/service.js index 80734a40d7b..1fd857946f9 100644 --- a/services/sync/modules/service.js +++ b/services/sync/modules/service.js @@ -603,9 +603,6 @@ WeaveSvc.prototype = { } } - // FIXME: too easy to generate a keypair. we should be absolutely certain - // that the keys are not there (404) and that it's not some other - // transient network problem instead let needKeys = true; let pubkey = yield PubKeys.getDefaultKey(self.cb); if (pubkey) { @@ -616,7 +613,6 @@ WeaveSvc.prototype = { ret = true; } } - if (needKeys) { if (PubKeys.lastResource.lastChannel.responseStatus != 404 && PrivKeys.lastResource.lastChannel.responseStatus != 404) { @@ -791,18 +787,23 @@ WeaveSvc.prototype = { } }, + // XXX deletes all known collections; we should have a way to delete + // everything on the server by querying it to get all collections _wipeServer: function WeaveSvc__wipeServer() { let self = yield; - // tmp, delete all known collections - for each (let coll in ["keys", "crypto", "clients", - "bookmarks", "history", "tabs"]) { - let res = new Resource(this.clusterURL + this.username + "/" + coll + "/"); + let engines = Engines.getAll(); + engines.push(Clients, {name: "keys"}, {name: "crypto"}); + for each (let engine in engines) { + let url = this.clusterURL + this.username + "/" + engine.name + "/"; + let res = new Resource(url); try { yield res.delete(self.cb); } catch (e) { this._log.debug("Exception on delete: " + Utils.exceptionStr(e)); } + if (engine.resetLastSync) + engine.resetLastSync(); } }, wipeServer: function WeaveSvc_wipeServer(onComplete) {