summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2017-06-12 23:06:55 +0300
committerLars Wirzenius <liw@liw.fi>2017-06-12 23:06:55 +0300
commitbf9c06f32f07a0b9ee29d38760ac7e826b66c922 (patch)
tree653908635fdc9d84d862a3422319aecedd0882f0
parent611a6c9ab9bfd86e93af943750b0ec5b4dde4e4a (diff)
downloadobnam-bf9c06f32f07a0b9ee29d38760ac7e826b66c922.tar.gz
fix things
-rw-r--r--obnamlib/fmt_ga/chunk_store.py15
-rw-r--r--obnamlib/fmt_ga/cowtree.py4
-rw-r--r--obnamlib/fmt_ga/indexes.py7
3 files changed, 20 insertions, 6 deletions
diff --git a/obnamlib/fmt_ga/chunk_store.py b/obnamlib/fmt_ga/chunk_store.py
index 35dcdca9..709eb00f 100644
--- a/obnamlib/fmt_ga/chunk_store.py
+++ b/obnamlib/fmt_ga/chunk_store.py
@@ -70,12 +70,19 @@ class GAChunkStore(object):
return bag_id
def get_chunks_in_bag(self, bag_id):
- bag = self._bag_store.get_bag(bag_id)
- for i in range(len(bag)):
- yield obnamlib.make_object_id(bag_id, i)
+ try:
+ bag = self._bag_store.get_bag(bag_id)
+ except EnvironmentError:
+ pass
+ else:
+ for i in range(len(bag)):
+ yield obnamlib.make_object_id(bag_id, i)
def remove_bag(self, bag_id):
- self._bag_store.remove_bag(bag_id)
+ try:
+ self._bag_store.remove_bag(bag_id)
+ except EnvironmentError:
+ pass
def has_chunk(self, chunk_id):
# This is ugly, 'cause it requires reading in the whole bag.
diff --git a/obnamlib/fmt_ga/cowtree.py b/obnamlib/fmt_ga/cowtree.py
index 80fe3bee..24093067 100644
--- a/obnamlib/fmt_ga/cowtree.py
+++ b/obnamlib/fmt_ga/cowtree.py
@@ -71,6 +71,10 @@ class CowTree(object):
self._leaf_list.drop_leaf(leaf_id)
self._store.remove_leaf(leaf_id)
self._split_leaf(leaf)
+ else:
+ self._leaf_list.drop_leaf(leaf_id)
+ self._make_split_leaf(leaf, list(sorted(leaf.keys())))
+ self._store.remove_leaf(leaf_id)
def _split_leaf(self, leaf):
sorted_keys = list(sorted(leaf.keys()))
diff --git a/obnamlib/fmt_ga/indexes.py b/obnamlib/fmt_ga/indexes.py
index 682b2c50..29169bac 100644
--- a/obnamlib/fmt_ga/indexes.py
+++ b/obnamlib/fmt_ga/indexes.py
@@ -127,6 +127,9 @@ class GAChunkIndexes(object):
def put_chunk_into_indexes(self, chunk_id, token, client_id):
self._load_data()
+ client_ids = self._used_by_tree.lookup(chunk_id)
+ logging.debug('xxx before adding to used-by: chunk %r is used by %r', chunk_id, client_ids)
+
self._by_chunk_id_tree.insert(chunk_id, token)
chunk_ids = self._by_checksum_tree.lookup(token)
@@ -136,7 +139,6 @@ class GAChunkIndexes(object):
chunk_ids.append(chunk_id)
self._by_checksum_tree.insert(token, chunk_ids)
- client_ids = self._used_by_tree.lookup(chunk_id)
if client_ids is None:
client_ids = [client_id]
elif client_id not in client_ids:
@@ -166,7 +168,7 @@ class GAChunkIndexes(object):
def _remove_used_by(self, chunk_id, client_id):
still_used = False
client_ids = self._used_by_tree.lookup(chunk_id)
- logging.debug('xxx chunk %r is used by %r', chunk_id, client_ids)
+ logging.debug('xxx before removing used_by: chunk %r is used by %r', chunk_id, client_ids)
if client_ids is not None and client_id in client_ids:
client_ids.remove(client_id)
self._used_by_tree.insert(chunk_id, client_ids)
@@ -176,6 +178,7 @@ class GAChunkIndexes(object):
# We leave an empty list, and use that in
# remove_unused_chunks to indicate an unused chunk.
pass
+ logging.debug('xxx after removing used_by: chunk %r is used by %r', chunk_id, client_ids)
return still_used
def _remove_chunk_by_id(self, chunk_id):