From 061821547dccc692b22c9262798702d498d75f6e Mon Sep 17 00:00:00 2001 From: Mike Connor Date: Tue, 29 Sep 2009 18:33:41 -0700 Subject: [PATCH] bug 518273 - need to handle not having an active node assigned, r=edilee --HG-- extra : rebase_source : f86c6cc164241cee263345de5e13dd5ae0a3758b --- services/sync/locales/en-US/sync.properties | 2 ++ services/sync/modules/constants.js | 1 + services/sync/modules/service.js | 20 ++++++++++++++++++-- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/services/sync/locales/en-US/sync.properties b/services/sync/locales/en-US/sync.properties index ba8ec37e9031..50b99b159af9 100644 --- a/services/sync/locales/en-US/sync.properties +++ b/services/sync/locales/en-US/sync.properties @@ -21,5 +21,7 @@ error.logout.title = Error While Signing Out error.logout.description = Weave encountered an error while signing you out. It's probably ok, and you don't have to do anything about it. error.sync.title = Error While Syncing error.sync.description = Weave encountered an error while syncing: %1$S. Weave will automatically retry this action. +error.sync.no_node_found = The Weave server is a little busy right now, but you don't need to do anything about it. We'll start syncing your data as soon as we can! +error.sync.no_node_found.title = Sync Delay error.sync.tryAgainButton.label = Sync Now error.sync.tryAgainButton.accesskey = S diff --git a/services/sync/modules/constants.js b/services/sync/modules/constants.js index 0bdc298a7df9..0e7628802186 100644 --- a/services/sync/modules/constants.js +++ b/services/sync/modules/constants.js @@ -101,6 +101,7 @@ NO_KEYS_NO_KEYGEN: "error.sync.reason.no_keys_no_keygen", KEYS_UPLOAD_FAIL: "error.sync.reason.keys_upload_fail", SETUP_FAILED_NO_PASSPHRASE: "error.sync.reason.setup_failed_no_passphrase", ABORT_SYNC_COMMAND: "aborting sync, process commands said so", +NO_SYNC_NODE_FOUND: "error.sync.reason.no_node_found", // engine failure status codes ENGINE_UPLOAD_FAIL: "error.engine.reason.record_upload_fail", diff --git a/services/sync/modules/service.js b/services/sync/modules/service.js index ae39edb7f712..31b46a527f33 100644 --- a/services/sync/modules/service.js +++ b/services/sync/modules/service.js @@ -489,6 +489,8 @@ WeaveSvc.prototype = { return this.serverURL; case 0: case 200: + if (node == "null") + node = null; return node; default: this._log.debug("Unexpected response code: " + node.status); @@ -505,6 +507,7 @@ WeaveSvc.prototype = { _setCluster: function _setCluster() { // Make sure we didn't get some unexpected response for the cluster let cluster = this._findCluster(); + this._log.debug("cluster value = " + cluster); if (cluster == null) return false; @@ -532,8 +535,13 @@ WeaveSvc.prototype = { _verifyLogin: function _verifyLogin() this._notify("verify-login", "", function() { // Make sure we have a cluster to verify against - if (this.clusterURL == "") - this._setCluster(); + // this is a little weird, if we don't get a node we pretend + // to succeed, since that probably means we just don't have storage + if (this.clusterURL == "" && !this._setCluster()) { + this.status.setSyncStatus(NO_SYNC_NODE_FOUND); + Svc.Observer.notifyObservers(null, "weave:service:sync:delayed", ""); + return true; + } try { let test = new Resource(this.infoURL).get(); @@ -1074,6 +1082,14 @@ WeaveSvc.prototype = { sync: function sync() this._catch(this._lock(this._notify("sync", "", function() { this.status.resetEngineStatus(); + + // if we don't have a node, get one. if that fails, retry in 10 minutes + if (this.clusterURL == "" && !this._setCluster()) { + this._scheduleNextSync(10 * 60 * 1000); + return; + } + + fullSync = true; // not doing thresholds yet // Make sure we should sync or record why we shouldn't let reason = this._checkSync();