From a2ec3129083b3528578dccd16c343ae281bd8d8f Mon Sep 17 00:00:00 2001 From: Dan Mills Date: Tue, 10 Feb 2009 13:29:04 -0800 Subject: [PATCH 1/4] allow multi-cluster support to be turned off --- services/sync/modules/service.js | 6 ++++++ services/sync/services-sync.js | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/services/sync/modules/service.js b/services/sync/modules/service.js index f5aa1a86557..f5d185f2e53 100644 --- a/services/sync/modules/service.js +++ b/services/sync/modules/service.js @@ -431,6 +431,12 @@ WeaveSvc.prototype = { findCluster: function WeaveSvc_findCluster(onComplete, username) { let fn = function WeaveSvc__findCluster() { let self = yield; + if (Svc.Prefs.get("independentNode")) { + this._log.debug("Using serverURL as data cluster (multi-cluster support disabled)"); + this.clusterURL = Svc.Prefs.get("serverURL"); + self.done(true); + return; + } this._log.debug("Finding cluster for user " + username); let res = new Resource(this.baseURL + "api/register/chknode/" + username); yield res.get(self.cb); diff --git a/services/sync/services-sync.js b/services/sync/services-sync.js index 1125355624a..e682be03ad4 100644 --- a/services/sync/services-sync.js +++ b/services/sync/services-sync.js @@ -1,4 +1,5 @@ pref("extensions.weave.serverURL", "https://services.mozilla.com/"); +pref("extensions.weave.independentNode", false); pref("extensions.weave.encryption", "aes-256-cbc"); @@ -16,7 +17,7 @@ pref("extensions.weave.syncOnQuit.enabled", true); pref("extensions.weave.engine.bookmarks", true); pref("extensions.weave.engine.history", true); -pref("extensions.weave.engine.cookies", true ); +pref("extensions.weave.engine.cookies", false); pref("extensions.weave.engine.passwords", false); pref("extensions.weave.engine.forms", false); pref("extensions.weave.engine.tabs", true); From a6a5e2c58e7eec72ecd97c072e4ee1c28e9f3258 Mon Sep 17 00:00:00 2001 From: Dan Mills Date: Tue, 10 Feb 2009 15:56:37 -0800 Subject: [PATCH 2/4] automatically try to detect if the server supports the multi-cluster call (hack hack hack) --- services/sync/modules/service.js | 23 ++++++++++++----------- services/sync/services-sync.js | 1 - 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/services/sync/modules/service.js b/services/sync/modules/service.js index f5d185f2e53..b63f95d567d 100644 --- a/services/sync/modules/service.js +++ b/services/sync/modules/service.js @@ -431,21 +431,22 @@ WeaveSvc.prototype = { findCluster: function WeaveSvc_findCluster(onComplete, username) { let fn = function WeaveSvc__findCluster() { let self = yield; - if (Svc.Prefs.get("independentNode")) { - this._log.debug("Using serverURL as data cluster (multi-cluster support disabled)"); - this.clusterURL = Svc.Prefs.get("serverURL"); - self.done(true); - return; - } + let ret = false; + this._log.debug("Finding cluster for user " + username); let res = new Resource(this.baseURL + "api/register/chknode/" + username); yield res.get(self.cb); - if (res.lastChannel.responseStatus != 200) { - self.done(false); - return; + + if (res.lastChannel.responseStatus == 404) { + this._log.debug("Using serverURL as data cluster (multi-cluster support disabled)"); + this.clusterURL = Svc.Prefs.get("serverURL"); + ret = true; + + } else if (res.lastChannel.responseStatus == 200) { + this.clusterURL = 'https://' + res.data + '/'; + ret = true; } - this.clusterURL = 'https://' + res.data + '/'; - self.done(true); + self.done(ret); }; fn.async(this, onComplete); }, diff --git a/services/sync/services-sync.js b/services/sync/services-sync.js index e682be03ad4..35b073a8f52 100644 --- a/services/sync/services-sync.js +++ b/services/sync/services-sync.js @@ -1,5 +1,4 @@ pref("extensions.weave.serverURL", "https://services.mozilla.com/"); -pref("extensions.weave.independentNode", false); pref("extensions.weave.encryption", "aes-256-cbc"); From a53adc5e28230b083e336a9ce7f05acf06c3c081 Mon Sep 17 00:00:00 2001 From: Dan Mills Date: Tue, 10 Feb 2009 17:50:40 -0800 Subject: [PATCH 3/4] catch exceptions when trying to find out user's cluster --- services/sync/modules/service.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/services/sync/modules/service.js b/services/sync/modules/service.js index b63f95d567d..08c59108dee 100644 --- a/services/sync/modules/service.js +++ b/services/sync/modules/service.js @@ -434,8 +434,10 @@ WeaveSvc.prototype = { let ret = false; this._log.debug("Finding cluster for user " + username); - let res = new Resource(this.baseURL + "api/register/chknode/" + username); - yield res.get(self.cb); + try { + let res = new Resource(this.baseURL + "api/register/chknode/" + username); + yield res.get(self.cb); + } catch (e) { /* we check status below */ } if (res.lastChannel.responseStatus == 404) { this._log.debug("Using serverURL as data cluster (multi-cluster support disabled)"); From d8982c54773ee76b43b109b1a31bf4b58eb32d9b Mon Sep 17 00:00:00 2001 From: Dan Mills Date: Tue, 10 Feb 2009 17:57:29 -0800 Subject: [PATCH 4/4] oops fix syntax error --- services/sync/modules/service.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/services/sync/modules/service.js b/services/sync/modules/service.js index 08c59108dee..d4243b9d028 100644 --- a/services/sync/modules/service.js +++ b/services/sync/modules/service.js @@ -434,8 +434,9 @@ WeaveSvc.prototype = { let ret = false; this._log.debug("Finding cluster for user " + username); + + let res = new Resource(this.baseURL + "api/register/chknode/" + username); try { - let res = new Resource(this.baseURL + "api/register/chknode/" + username); yield res.get(self.cb); } catch (e) { /* we check status below */ }