diff options
author | Lars Wirzenius <liw@liw.fi> | 2010-12-27 21:00:52 +0000 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2010-12-27 21:00:52 +0000 |
commit | ea3bd67c13c867a590523ef540af1c5de603f85e (patch) | |
tree | b66b0d81f55e868a7afc7ef5831d6fc614e7e87e | |
parent | 26e6edfcffd5239d23c8fb5fd1f0c6d74cee39d9 (diff) | |
download | obnam-ea3bd67c13c867a590523ef540af1c5de603f85e.tar.gz |
Deal with empty forests.
In various places we were assuming that if init_forest returned
true, then self.forest.trees was non-empty, but that's not always
the case.
-rw-r--r-- | obnamlib/checksumtree.py | 4 | ||||
-rw-r--r-- | obnamlib/chunklist.py | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/obnamlib/checksumtree.py b/obnamlib/checksumtree.py index 43e27ed4..061ca255 100644 --- a/obnamlib/checksumtree.py +++ b/obnamlib/checksumtree.py @@ -48,7 +48,7 @@ class ChecksumTree(obnamlib.StoreTree): self.tree.insert(key, '') def find(self, checksum): - if self.init_forest(): + if self.init_forest() and self.forest.trees: minkey = self.key(checksum, 0, 0) maxkey = self.key(checksum, obnamlib.MAX_ID, obnamlib.MAX_ID) t = self.forest.trees[-1] @@ -64,7 +64,7 @@ class ChecksumTree(obnamlib.StoreTree): def chunk_is_used(self, checksum, chunk_id): '''Is a given chunk used by anyone?''' - if self.init_forest(): + if self.init_forest() and self.forest.trees: minkey = self.key(checksum, chunk_id, 0) maxkey = self.key(checksum, chunk_id, obnamlib.MAX_ID) t = self.forest.trees[-1] diff --git a/obnamlib/chunklist.py b/obnamlib/chunklist.py index 8c651bfa..66a2d11b 100644 --- a/obnamlib/chunklist.py +++ b/obnamlib/chunklist.py @@ -46,7 +46,7 @@ class ChunkList(obnamlib.StoreTree): self.tree.insert(self.key(chunk_id), checksum) def get_checksum(self, chunk_id): - if self.init_forest(): + if self.init_forest() and self.forest.trees: t = self.forest.trees[-1] return t.lookup(self.key(chunk_id)) raise KeyError(chunk_id) |