diff options
author | Lars Wirzenius <liw@liw.fi> | 2016-08-13 15:41:23 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2016-08-14 10:11:50 +0300 |
commit | b88b51305f7b96077e5ee0517248dc45029c9d4f (patch) | |
tree | 7a677556986ac08481f6ff87da90c6da6f1da135 /obnamlib/fmt_ga/leaf_store.py | |
parent | 7d461c35e49f8f0c9922fc4f52d306a186e44106 (diff) | |
download | obnam-b88b51305f7b96077e5ee0517248dc45029c9d4f.tar.gz |
Add CowTree for storing chunk index data
Also, add a a real implementation of LeafStore, with persistence.
Diffstat (limited to 'obnamlib/fmt_ga/leaf_store.py')
-rw-r--r-- | obnamlib/fmt_ga/leaf_store.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/obnamlib/fmt_ga/leaf_store.py b/obnamlib/fmt_ga/leaf_store.py index 5a3a8627..b5cb5120 100644 --- a/obnamlib/fmt_ga/leaf_store.py +++ b/obnamlib/fmt_ga/leaf_store.py @@ -16,6 +16,9 @@ # =*= License: GPL-3+ =*= +import obnamlib + + class LeafStoreInterface(object): # pragma: no cover def put_leaf(self, leaf): @@ -38,3 +41,20 @@ class InMemoryLeafStore(LeafStoreInterface): def get_leaf(self, leaf_id): return self._leaves.get(leaf_id, None) + + +class LeafStore(LeafStoreInterface): # pragma: no cover + + def __init__(self): + self._blob_store = None + + def set_blob_store(self, blob_store): + self._blob_store = blob_store + + def put_leaf(self, leaf): + return self._blob_store.put_blob(leaf.as_dict()) + + def get_leaf(self, leaf_id): + leaf = obnamlib.CowLeaf() + leaf.from_dict(self._blob_store.get_blob(leaf_id)) + return leaf |