diff options
author | drebs <drebs@leap.se> | 2017-02-23 19:01:17 -0300 |
---|---|---|
committer | drebs <drebs@leap.se> | 2017-02-23 19:42:55 -0300 |
commit | 67fc01d1b055b4a0ff3742ba4c3d32bbef3e1b87 (patch) | |
tree | 0274d295241a35cdd95c92174b702e8e4f7b5362 /client/src/leap | |
parent | 75e4d4e7dafe4472ee55fa0159eeb8270df2dd49 (diff) |
[feature] add offline status to soledad client api
Diffstat (limited to 'client/src/leap')
-rw-r--r-- | client/src/leap/soledad/client/api.py | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/client/src/leap/soledad/client/api.py b/client/src/leap/soledad/client/api.py index 07eb8e9e..16569ec2 100644 --- a/client/src/leap/soledad/client/api.py +++ b/client/src/leap/soledad/client/api.py @@ -128,7 +128,7 @@ class Soledad(object): def __init__(self, uuid, passphrase, secrets_path, local_db_path, server_url, cert_file, shared_db=None, - auth_token=None): + auth_token=None, offline=False): """ Initialize configuration, cryptographic keys and dbs. @@ -165,10 +165,11 @@ class Soledad(object): Authorization token for accessing remote databases. :type auth_token: str - :param syncable: - If set to ``False``, this database will not attempt to synchronize - with remote replicas (default is ``True``) - :type syncable: bool + :param offline: + If set to ``True``, this database will not attempt to save/load + secrets to/from server or synchronize with remote replicas (default + is ``False``) + :type offline: bool :raise BootstrapSequenceError: Raised when the secret initialization sequence (i.e. retrieval @@ -182,6 +183,7 @@ class Soledad(object): self._server_url = server_url self._secrets_path = None self._dbsyncer = None + self._offline = offline # configure SSL certificate global SOLEDAD_CERT @@ -212,6 +214,14 @@ class Soledad(object): self._dbpool.close() raise + def _get_offline(self): + return self._offline + + def _set_offline(self, offline): + self._offline = offline + + offline = property(_get_offline, _set_offline) + # # initialization/destruction methods # @@ -660,8 +670,8 @@ class Soledad(object): generation before the synchronization was performed. :rtype: twisted.internet.defer.Deferred """ - # bypass sync if there's no token set - if not self.token: + # maybe bypass sync + if self.offline or not self.token: generation = self._dbsyncer.get_generation() return defer.succeed(generation) |