diff options
author | Lars Wirzenius <liw@liw.fi> | 2017-06-11 18:27:14 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2017-06-13 19:39:33 +0300 |
commit | bfaa23c896df72b8b34ad70c723d05a206a56c19 (patch) | |
tree | f32cd3cebbc6190efa8507b444b2d0629baf1187 /obnamlib/fmt_ga/leaf_store.py | |
parent | 761c367c9d2a101fc92b225cc234f1da5d28f4bf (diff) | |
download | obnam-bfaa23c896df72b8b34ad70c723d05a206a56c19.tar.gz |
Fix: Make "obnam forget" for GA delete unused chunks
Diffstat (limited to 'obnamlib/fmt_ga/leaf_store.py')
-rw-r--r-- | obnamlib/fmt_ga/leaf_store.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/obnamlib/fmt_ga/leaf_store.py b/obnamlib/fmt_ga/leaf_store.py index 5d488e96..56b08faa 100644 --- a/obnamlib/fmt_ga/leaf_store.py +++ b/obnamlib/fmt_ga/leaf_store.py @@ -1,4 +1,4 @@ -# Copyright 2016 Lars Wirzenius +# Copyright 2016-2017 Lars Wirzenius # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -27,6 +27,9 @@ class LeafStoreInterface(object): # pragma: no cover def get_leaf(self, leaf_id): raise NotImplementedError() + def remove_leaf(self, leaf_id): + raise NotImplementedError() + def flush(self): raise NotImplementedError() @@ -45,6 +48,10 @@ class InMemoryLeafStore(LeafStoreInterface): def get_leaf(self, leaf_id): return self._leaves.get(leaf_id, None) + def remove_leaf(self, leaf_id): + if leaf_id in self._leaves: + del self._leaves[leaf_id] + def flush(self): pass @@ -65,5 +72,11 @@ class LeafStore(LeafStoreInterface): # pragma: no cover leaf.from_dict(self._blob_store.get_blob(leaf_id)) return leaf + def remove_leaf(self, leaf_id): + # FIXME: This is a bit ugly, since we need to break the + # bag/blob store abstraction. + bag_id, _ = obnamlib.parse_object_id(leaf_id) + self._blob_store._bag_store.remove_bag(bag_id) + def flush(self): self._blob_store.flush() |