summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRuben Pollan <meskio@sindominio.net>2016-09-30 17:36:12 -0500
committerKali Kaneko (leap communications) <kali@leap.se>2016-10-04 01:43:34 -0400
commitde0ac2dd999a0548f2276cd2e2715ca93cb6b41b (patch)
tree42ce8c56d080886c698823b553068c5c3b9cb0f9 /src
parent8589bd13c7aa9054dc27d8b3be5ede9ebffb6abe (diff)
[bug] In case of wrong url don't leave files in the config folder
- Resolves: #8498
Diffstat (limited to 'src')
-rw-r--r--src/leap/bitmask/bonafide/_protocol.py2
-rw-r--r--src/leap/bitmask/bonafide/config.py14
-rw-r--r--src/leap/bitmask/bonafide/errors.py4
3 files changed, 16 insertions, 4 deletions
diff --git a/src/leap/bitmask/bonafide/_protocol.py b/src/leap/bitmask/bonafide/_protocol.py
index 01919c7..3572cbf 100644
--- a/src/leap/bitmask/bonafide/_protocol.py
+++ b/src/leap/bitmask/bonafide/_protocol.py
@@ -168,7 +168,7 @@ class BonafideProtocol(object):
def do_get_provider(self, provider_id, autoconf=False):
provider = config.Provider(provider_id, autoconf=autoconf)
- return provider.callWhenMainConfigReady(provider.config)
+ return provider.callWhenReady(provider.config)
def do_provider_delete(self, provider_id):
return config.delete_provider(provider_id)
diff --git a/src/leap/bitmask/bonafide/config.py b/src/leap/bitmask/bonafide/config.py
index 8ef6c1b..e4e2bf4 100644
--- a/src/leap/bitmask/bonafide/config.py
+++ b/src/leap/bitmask/bonafide/config.py
@@ -33,7 +33,7 @@ from twisted.web.client import Agent, downloadPage
from leap.bitmask.bonafide._http import httpRequest
from leap.bitmask.bonafide.provider import Discovery
-from leap.bitmask.bonafide.errors import NotConfiguredError
+from leap.bitmask.bonafide.errors import NotConfiguredError, NetworkError
from leap.common.check import leap_assert
from leap.common.config import get_path_prefix as common_get_path_prefix
@@ -284,9 +284,13 @@ class Provider(object):
uri = self._disco.get_provider_info_uri()
met = self._disco.get_provider_info_method()
+ def errback(failure):
+ shutil.rmtree(folders)
+ raise NetworkError(failure.getErrorMessage())
+
d = downloadPage(uri, provider_json, method=met)
d.addCallback(lambda _: self._load_provider_json())
- d.addErrback(log.err)
+ d.addErrback(errback)
return d
def update_provider_info(self):
@@ -299,6 +303,10 @@ class Provider(object):
"""
:rtype: deferred
"""
+
+ def errback(self, failure):
+ raise NetworkError(failure.getErrorMessage())
+
path = self._get_ca_cert_path()
if is_file(path):
return defer.succeed('ca_cert_path_already_exists')
@@ -306,7 +314,7 @@ class Provider(object):
uri = self._get_ca_cert_uri()
mkdir_p(os.path.split(path)[0])
d = downloadPage(uri, path)
- d.addErrback(log.err)
+ d.addErrback(errback)
return d
def validate_ca_cert(self, ignored):
diff --git a/src/leap/bitmask/bonafide/errors.py b/src/leap/bitmask/bonafide/errors.py
index 485c43e..db92519 100644
--- a/src/leap/bitmask/bonafide/errors.py
+++ b/src/leap/bitmask/bonafide/errors.py
@@ -21,3 +21,7 @@ Exceptions for bonafide
class NotConfiguredError(Exception):
pass
+
+
+class NetworkError(Exception):
+ pass