From f4fab23bf63c4c5a786048561a1232f7f4521db7 Mon Sep 17 00:00:00 2001 From: Zooko O'Whielacronx Date: Mon, 5 Jan 2009 14:01:14 -0700 Subject: [PATCH] immutable: raise a LayoutInvalid exception instead of an AssertionError if the share is corrupted so that the sharehashtree is the wrong size --- src/allmydata/immutable/layout.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/allmydata/immutable/layout.py b/src/allmydata/immutable/layout.py index 07d1131f..8ab6e1db 100644 --- a/src/allmydata/immutable/layout.py +++ b/src/allmydata/immutable/layout.py @@ -414,7 +414,8 @@ class ReadBucketProxy: end of the share, so we need to use the offset and read just that much.""" offset = self._offsets['share_hashes'] size = self._offsets['uri_extension'] - offset - assert size % (2+HASH_SIZE) == 0 + if size % (2+HASH_SIZE) != 0: + raise LayoutInvalid("share hash tree corrupted -- should occupy a multiple of %d bytes, not %d bytes" % ((2+HASH_SIZE), size)) d = self._read(offset, size) def _unpack_share_hashes(data): assert len(data) == size -- 2.45.2