mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-30 09:48:56 +00:00
mutable: fix usage of NeedMoreDataError
This commit is contained in:
parent
c783128012
commit
247bfe8d58
@ -18,6 +18,8 @@ class NeedMoreDataError(Exception):
|
|||||||
def __init__(self, needed_bytes):
|
def __init__(self, needed_bytes):
|
||||||
Exception.__init__(self)
|
Exception.__init__(self)
|
||||||
self.needed_bytes = needed_bytes
|
self.needed_bytes = needed_bytes
|
||||||
|
def __str__(self):
|
||||||
|
return "<NeedMoreDataError (%d bytes)>" % self.needed_bytes
|
||||||
|
|
||||||
class UncoordinatedWriteError(Exception):
|
class UncoordinatedWriteError(Exception):
|
||||||
pass
|
pass
|
||||||
@ -372,7 +374,7 @@ class Retrieve:
|
|||||||
return
|
return
|
||||||
if f.check(NeedMoreDataError):
|
if f.check(NeedMoreDataError):
|
||||||
# ah, just re-send the query then.
|
# ah, just re-send the query then.
|
||||||
self._read_size = max(self._read_size, f.needed_bytes)
|
self._read_size = max(self._read_size, f.value.needed_bytes)
|
||||||
(conn, storage_index, peer_storage_servers) = stuff
|
(conn, storage_index, peer_storage_servers) = stuff
|
||||||
self._do_query(conn, peerid, storage_index, self._read_size,
|
self._do_query(conn, peerid, storage_index, self._read_size,
|
||||||
peer_storage_servers)
|
peer_storage_servers)
|
||||||
|
@ -181,7 +181,16 @@ def dump_SDMF_share(offset, length, config, out, err):
|
|||||||
data = f.read(min(length, 2000))
|
data = f.read(min(length, 2000))
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
pieces = mutable.unpack_share(data)
|
try:
|
||||||
|
pieces = mutable.unpack_share(data)
|
||||||
|
except mutable.NeedMoreDataError, e:
|
||||||
|
# retry once with the larger size
|
||||||
|
size = e.needed_bytes
|
||||||
|
f = open(config['filename'], "rb")
|
||||||
|
f.seek(offset)
|
||||||
|
data = f.read(min(length, size))
|
||||||
|
f.close()
|
||||||
|
pieces = mutable.unpack_share(data)
|
||||||
|
|
||||||
(seqnum, root_hash, IV, k, N, segsize, datalen,
|
(seqnum, root_hash, IV, k, N, segsize, datalen,
|
||||||
pubkey, signature, share_hash_chain, block_hash_tree,
|
pubkey, signature, share_hash_chain, block_hash_tree,
|
||||||
|
Loading…
Reference in New Issue
Block a user