diff options
author | Lars Wirzenius <liw@liw.fi> | 2015-05-16 18:27:24 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2015-05-16 19:06:29 +0300 |
commit | 68e18a105bc9bca499895bf39bb5cffcf63d3dbf (patch) | |
tree | 979ef260d0691a92e4e90ffa6bdfc8e2bcefc940 | |
parent | 246bb669a27278ecb73e93c0e1b0ad0393a2e32f (diff) | |
download | obnam-68e18a105bc9bca499895bf39bb5cffcf63d3dbf.tar.gz |
Add RepositoryInterface.flush_chunks method
-rw-r--r-- | obnamlib/delegator.py | 3 | ||||
-rw-r--r-- | obnamlib/fmt_6/repo_fmt_6.py | 3 | ||||
-rw-r--r-- | obnamlib/fmt_ga/chunk_store.py | 3 | ||||
-rw-r--r-- | obnamlib/fmt_simple/simple.py | 3 | ||||
-rw-r--r-- | obnamlib/plugins/backup_plugin.py | 3 | ||||
-rw-r--r-- | obnamlib/plugins/forget_plugin.py | 1 | ||||
-rw-r--r-- | obnamlib/repo_dummy.py | 3 | ||||
-rw-r--r-- | obnamlib/repo_interface.py | 10 |
8 files changed, 29 insertions, 0 deletions
diff --git a/obnamlib/delegator.py b/obnamlib/delegator.py index 861d6453..42564856 100644 --- a/obnamlib/delegator.py +++ b/obnamlib/delegator.py @@ -277,6 +277,9 @@ class RepositoryDelegator(obnamlib.RepositoryInterface): def remove_chunk(self, chunk_id): return self._chunk_store.remove_chunk(chunk_id) + def flush_chunks(self): + self._chunk_store.flush_chunks() + def get_chunk_ids(self): return self._chunk_store.get_chunk_ids() diff --git a/obnamlib/fmt_6/repo_fmt_6.py b/obnamlib/fmt_6/repo_fmt_6.py index 21500f80..1c179773 100644 --- a/obnamlib/fmt_6/repo_fmt_6.py +++ b/obnamlib/fmt_6/repo_fmt_6.py @@ -679,6 +679,9 @@ class RepositoryFormat6(obnamlib.RepositoryInterface): chunk_id=str(chunk_id), filename=filename) + def flush_chunks(self): + pass + def get_chunk_ids(self): # Note: This does not cover for in-tree chunk data. We cannot # realistically iterate over all per-client B-trees to find diff --git a/obnamlib/fmt_ga/chunk_store.py b/obnamlib/fmt_ga/chunk_store.py index 2a0562b9..7232d39a 100644 --- a/obnamlib/fmt_ga/chunk_store.py +++ b/obnamlib/fmt_ga/chunk_store.py @@ -65,6 +65,9 @@ class GAChunkStore(object): filename=filename) self._fs.remove(filename) + def flush_chunks(self): + pass + def get_chunk_ids(self): if not self._fs.exists(self._dirname): return [] diff --git a/obnamlib/fmt_simple/simple.py b/obnamlib/fmt_simple/simple.py index e995c97a..2e0b3a08 100644 --- a/obnamlib/fmt_simple/simple.py +++ b/obnamlib/fmt_simple/simple.py @@ -446,6 +446,9 @@ class SimpleChunkStore(object): filename=filename) self._fs.remove(filename) + def flush_chunks(self): + pass + def get_chunk_ids(self): if not self._fs.exists(self._dirname): return [] diff --git a/obnamlib/plugins/backup_plugin.py b/obnamlib/plugins/backup_plugin.py index 58cebc99..2dacd67a 100644 --- a/obnamlib/plugins/backup_plugin.py +++ b/obnamlib/plugins/backup_plugin.py @@ -402,6 +402,7 @@ class BackupPlugin(obnamlib.ObnamPlugin): False) self.progress.what(prefix + 'committing client') + self.repo.flush_chunks() self.repo.commit_client(self.client_name) self.progress.what(prefix + 'committing shared B-trees') @@ -423,6 +424,7 @@ class BackupPlugin(obnamlib.ObnamPlugin): self.repo.remove_generation(gen) self.progress.what(prefix + ': committing client') + self.repo.flush_chunks() self.repo.commit_client(self.client_name) self.progress.what(prefix + ': commiting shared B-trees') @@ -649,6 +651,7 @@ class BackupPlugin(obnamlib.ObnamPlugin): self.repo.set_generation_key( self.new_generation, obnamlib.REPO_GENERATION_IS_CHECKPOINT, 1) + self.repo.flush_chunks() self.repo.commit_client(self.client_name) self.progress.what('making checkpoint: committing shared B-trees') self.repo.commit_chunk_indexes() diff --git a/obnamlib/plugins/forget_plugin.py b/obnamlib/plugins/forget_plugin.py index 6f49a138..67e122fc 100644 --- a/obnamlib/plugins/forget_plugin.py +++ b/obnamlib/plugins/forget_plugin.py @@ -123,6 +123,7 @@ class ForgetPlugin(obnamlib.ObnamPlugin): self.repo.unlock_client_list() for some_client_name in client_names: if some_client_name == client_name: + self.repo.flush_chunks() self.repo.commit_client(some_client_name) else: self.repo.unlock_client(some_client_name) diff --git a/obnamlib/repo_dummy.py b/obnamlib/repo_dummy.py index 09664fee..71a3d28f 100644 --- a/obnamlib/repo_dummy.py +++ b/obnamlib/repo_dummy.py @@ -700,6 +700,9 @@ class RepositoryFormatDummy(obnamlib.RepositoryInterface): def remove_chunk(self, chunk_id): self._chunk_store.remove_chunk(chunk_id) + def flush_chunks(self): + pass + def get_chunk_ids(self): return self._chunk_store.get_chunk_ids() diff --git a/obnamlib/repo_interface.py b/obnamlib/repo_interface.py index b39f8abe..540d1590 100644 --- a/obnamlib/repo_interface.py +++ b/obnamlib/repo_interface.py @@ -700,6 +700,10 @@ class RepositoryInterface(object): '''Generate all chunk ids in repository.''' raise NotImplementedError() + def flush_chunks(self): + '''Flush any pending chunks.''' + raise NotImplementedError() + def lock_chunk_indexes(self): '''Locks chunk indexes for updates.''' raise NotImplementedError() @@ -1840,6 +1844,12 @@ class RepositoryInterfaceTests(unittest.TestCase): # pragma: no cover def test_puts_chunk_into_repository(self): chunk_id = self.repo.put_chunk_content('foochunk') + self.repo.flush_chunks() + self.assertTrue(self.repo.has_chunk(chunk_id)) + self.assertEqual(self.repo.get_chunk_content(chunk_id), 'foochunk') + + def test_finds_put_chunk_in_unflushed_repository(self): + chunk_id = self.repo.put_chunk_content('foochunk') self.assertTrue(self.repo.has_chunk(chunk_id)) self.assertEqual(self.repo.get_chunk_content(chunk_id), 'foochunk') |