diff options
author | Lars Wirzenius <liw@liw.fi> | 2010-12-07 11:32:38 +0000 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2010-12-07 11:32:38 +0000 |
commit | e5cec47fc22f69a3db41fb6d0b34577970269a5c (patch) | |
tree | 15a8d228b9d00dac992d734b02b35d167fa46a45 | |
parent | 2bdb0fac50badb82ebb5f57e3bb5ed107d8ae1d4 (diff) | |
download | obnam-e5cec47fc22f69a3db41fb6d0b34577970269a5c.tar.gz |
Change ChunkList to use new StoreTree stuff.
-rw-r--r-- | obnamlib/chunklist.py | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/obnamlib/chunklist.py b/obnamlib/chunklist.py index 60859283..10bd7a69 100644 --- a/obnamlib/chunklist.py +++ b/obnamlib/chunklist.py @@ -41,22 +41,16 @@ class ChunkList(obnamlib.StoreTree): return struct.pack('!Q', chunk_id) def add(self, chunk_id, checksum): - self.require_forest() - if not self.forest.trees: - t = self.forest.new_tree() - else: - t = self.forest.trees[-1] - t.insert(self.key(chunk_id), checksum) + self.start_changes() + self.tree.insert(self.key(chunk_id), checksum) def get_checksum(self, chunk_id): - if self.init_forest() and self.forest.trees: - return self.forest.trees[-1].lookup(self.key(chunk_id)) + if self.init_forest() and self.tree: + return self.tree.lookup(self.key(chunk_id)) raise KeyError(chunk_id) def remove(self, chunk_id): - self.require_forest() - if self.forest.trees: - t = self.forest.trees[-1] - key = self.key(chunk_id) - t.remove_range(key, key) + self.start_changes() + key = self.key(chunk_id) + self.tree.remove_range(key, key) |