summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--obnamlib/plugins/encryption_plugin.py10
-rw-r--r--obnamlib/repo_dummy.py3
-rw-r--r--obnamlib/repo_fmt_6.py5
-rw-r--r--obnamlib/repo_interface.py27
-rw-r--r--test-gpghome/random_seedbin600 -> 600 bytes
5 files changed, 37 insertions, 8 deletions
diff --git a/obnamlib/plugins/encryption_plugin.py b/obnamlib/plugins/encryption_plugin.py
index c1d734b6..aeebe217 100644
--- a/obnamlib/plugins/encryption_plugin.py
+++ b/obnamlib/plugins/encryption_plugin.py
@@ -248,14 +248,8 @@ class EncryptionPlugin(obnamlib.ObnamPlugin):
_shared = ['chunklist', 'chunks', 'chunksums', 'clientlist']
def _find_clientdirs(self, repo, client_names):
- result = []
- for client_name in client_names:
- client_id = repo._client_list.get_client_id(client_name)
- if client_id:
- result.append(str(client_id))
- else:
- logging.warning("client not found: %s" % client_name)
- return result
+ return [repo.get_client_extra_data_directory(client_name)
+ for client_name in client_names]
def add_key(self, args):
'''Add a key to the repository.'''
diff --git a/obnamlib/repo_dummy.py b/obnamlib/repo_dummy.py
index 17a21251..f1fcaa2d 100644
--- a/obnamlib/repo_dummy.py
+++ b/obnamlib/repo_dummy.py
@@ -553,6 +553,9 @@ class RepositoryFormatDummy(obnamlib.RepositoryInterface):
def get_client_generation_ids(self, client_name):
return self._client_list[client_name].get_generation_ids()
+ def get_client_extra_data_directory(self, client_name):
+ return client_name
+
def create_generation(self, client_name):
return self._client_list[client_name].create_generation()
diff --git a/obnamlib/repo_fmt_6.py b/obnamlib/repo_fmt_6.py
index 59b92dc0..487db598 100644
--- a/obnamlib/repo_fmt_6.py
+++ b/obnamlib/repo_fmt_6.py
@@ -442,6 +442,11 @@ class RepositoryFormat6(obnamlib.RepositoryInterface):
return (client_name, open_client.current_generation_number)
+ def get_client_extra_data_directory(self, client_name):
+ tracing.trace('client_name=%s', client_name)
+ self._require_existing_client(client_name)
+ return str(self._get_client_id(client_name))
+
# Generations for a client.
def _require_existing_generation(self, generation_id):
diff --git a/obnamlib/repo_interface.py b/obnamlib/repo_interface.py
index 77200370..5010ea58 100644
--- a/obnamlib/repo_interface.py
+++ b/obnamlib/repo_interface.py
@@ -486,6 +486,27 @@ class RepositoryInterface(object):
'''
raise NotImplementedError()
+ def get_client_extra_data_directory(self, client_name):
+ '''Return directory for storing extra data for a client.
+
+ Obnam plugins, for example, may need to store some per-client
+ data that is specific to the plugin. This might be any kind of
+ data, making it unsuitable for file keys (see get_file_key),
+ which are suitable only for small bits of data.. The extra
+ data might further need to be written in raw format. As an
+ example, a hypothetical plugin might put the source code that
+ of the Obnam version the client is using into the repository,
+ to increase the chance that data can be restored even if only
+ the repository remains. Or an encryption plugin might store
+ encryption keys for the client here.
+
+ This method returns the name of a directory, useable as-is
+ with the VFS instance returned by the get_fs method.
+
+ '''
+
+ raise NotImplementedError()
+
# Generations. The generation id identifies client as well.
def get_allowed_generation_keys(self):
@@ -1216,6 +1237,12 @@ class RepositoryInterfaceTests(unittest.TestCase): # pragma: no cover
self.repo.get_client_generation_ids('fooclient'),
[new_id])
+ def test_returns_direcotry_name_for_extra_data(self):
+ self.setup_client()
+ self.assertTrue(
+ type(self.repo.get_client_extra_data_directory('fooclient')),
+ str)
+
# Operations on one generation.
def create_generation(self):
diff --git a/test-gpghome/random_seed b/test-gpghome/random_seed
index e1fd53c3..85b5a4f8 100644
--- a/test-gpghome/random_seed
+++ b/test-gpghome/random_seed
Binary files differ