summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2015-12-21 19:24:16 +0100
committerLars Wirzenius <liw@liw.fi>2015-12-21 22:38:37 +0100
commit67abb6ad1091722617c7517d3d9100bf60af7ac0 (patch)
treeda1adf499b1203955b4a8d100e707c7d52d7ce3b
parent637fc8bc3843d9f1f77f75cc5c2e12e0ec594270 (diff)
downloadobnam-67abb6ad1091722617c7517d3d9100bf60af7ac0.tar.gz
Make remove_unused_chunks require chunk indexes lock
Also, move remove_unused_chunks to chunk indexes.
-rw-r--r--obnamlib/delegator.py9
-rw-r--r--obnamlib/fmt_6/repo_fmt_6.py1
-rw-r--r--obnamlib/fmt_ga/chunk_store.py4
-rw-r--r--obnamlib/fmt_ga/indexes.py4
4 files changed, 11 insertions, 7 deletions
diff --git a/obnamlib/delegator.py b/obnamlib/delegator.py
index 3551fc78..c873374a 100644
--- a/obnamlib/delegator.py
+++ b/obnamlib/delegator.py
@@ -302,9 +302,6 @@ class RepositoryDelegator(obnamlib.RepositoryInterface):
def flush_chunks(self):
self._chunk_store.flush_chunks()
- def remove_unused_chunks(self):
- return self._chunk_store.remove_unused_chunks()
-
def get_chunk_ids(self):
return self._chunk_store.get_chunk_ids()
@@ -365,6 +362,12 @@ class RepositoryDelegator(obnamlib.RepositoryInterface):
self._require_we_got_chunk_indexes_lock()
self._chunk_indexes.remove_chunk_from_indexes_for_all_clients(chunk_id)
+ def remove_unused_chunks(self):
+ self._require_we_got_chunk_indexes_lock()
+ # Note that we need to give remove_unused_chunks the chunk
+ # store as an argument, so that it can actually remove chunks.
+ return self._chunk_indexes.remove_unused_chunks(self._chunk_store)
+
def validate_chunk_content(self, chunk_id):
return self._chunk_indexes.validate_chunk_content(chunk_id)
diff --git a/obnamlib/fmt_6/repo_fmt_6.py b/obnamlib/fmt_6/repo_fmt_6.py
index cd389af2..f2bf37d4 100644
--- a/obnamlib/fmt_6/repo_fmt_6.py
+++ b/obnamlib/fmt_6/repo_fmt_6.py
@@ -666,6 +666,7 @@ class RepositoryFormat6(obnamlib.RepositoryInterface):
pass
def remove_unused_chunks(self): # pragma: no cover
+ self._require_chunk_indexes_lock()
for chunk_id in self._unused_chunks:
self._remove_chunk(chunk_id)
self._reset_unused_chunks()
diff --git a/obnamlib/fmt_ga/chunk_store.py b/obnamlib/fmt_ga/chunk_store.py
index dcb920bb..9f916276 100644
--- a/obnamlib/fmt_ga/chunk_store.py
+++ b/obnamlib/fmt_ga/chunk_store.py
@@ -57,10 +57,6 @@ class GAChunkStore(object):
def flush_chunks(self):
self._blob_store.flush()
- def remove_unused_chunks(self):
- # FIXME: This is a no-op operation, for now.
- pass
-
def get_chunk_content(self, chunk_id):
content = self._blob_store.get_blob(chunk_id)
if content is None:
diff --git a/obnamlib/fmt_ga/indexes.py b/obnamlib/fmt_ga/indexes.py
index 582fa77a..8c6cc5f2 100644
--- a/obnamlib/fmt_ga/indexes.py
+++ b/obnamlib/fmt_ga/indexes.py
@@ -148,5 +148,9 @@ class GAChunkIndexes(object):
if chunk_id in used_by:
del used_by[chunk_id]
+ def remove_unused_chunks(self, chunk_store):
+ # FIXME: This is a no-op operation, for now.
+ pass
+
def validate_chunk_content(self, chunk_id):
return None