summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2015-08-02 17:49:46 +0300
committerLars Wirzenius <liw@liw.fi>2015-08-02 18:44:02 +0300
commit5b0c45e2393d01fe72b761b9a211b162ee004f1b (patch)
tree5c5684b62e324ffcf2d1b83a9f904c3c7ff43ef5
parentbf154f2ba6b5cec13b3bf56e9488fbaa64734689 (diff)
downloadobnam-5b0c45e2393d01fe72b761b9a211b162ee004f1b.tar.gz
Make ClientFinder look up in cache first
Also, maintain cache correctly.
-rw-r--r--obnamlib/delegator.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/obnamlib/delegator.py b/obnamlib/delegator.py
index b1240fce..68e932b8 100644
--- a/obnamlib/delegator.py
+++ b/obnamlib/delegator.py
@@ -111,6 +111,7 @@ class RepositoryDelegator(obnamlib.RepositoryInterface):
def remove_client(self, client_name):
self._require_we_got_client_list_lock()
self._client_list.remove_client(client_name)
+ self._client_finder.remove_client(client_name)
def rename_client(self, old_client_name, new_client_name):
self._require_we_got_client_list_lock()
@@ -363,11 +364,11 @@ class ClientFinder(object):
self._current_time = current_time
def find_client(self, client_name):
- if client_name not in self._client_list.get_client_names():
- raise obnamlib.RepositoryClientDoesNotExist(
- client_name=client_name)
-
if client_name not in self._clients:
+ if client_name not in self._client_list.get_client_names():
+ raise obnamlib.RepositoryClientDoesNotExist(
+ client_name=client_name)
+
client = self._client_factory(client_name)
client.set_fs(self._fs)
dirname = self._client_list.get_client_dirname(client_name)
@@ -377,6 +378,10 @@ class ClientFinder(object):
return self._clients[client_name]
+ def remove_client(self, client_name):
+ if client_name in self._clients:
+ del self._clients[client_name]
+
class GenerationId(object):