]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
mutable: fix usage of NeedMoreDataError
authorBrian Warner <warner@allmydata.com>
Thu, 8 Nov 2007 00:52:09 +0000 (17:52 -0700)
committerBrian Warner <warner@allmydata.com>
Thu, 8 Nov 2007 00:52:09 +0000 (17:52 -0700)
src/allmydata/mutable.py
src/allmydata/scripts/debug.py

index aa44dcc6fef952a109f4b29f595f0380a11fa1ac..d97e76fd8139163afc41de84fabdc3256c410bd6 100644 (file)
@@ -18,6 +18,8 @@ class NeedMoreDataError(Exception):
     def __init__(self, needed_bytes):
         Exception.__init__(self)
         self.needed_bytes = needed_bytes
+    def __str__(self):
+        return "<NeedMoreDataError (%d bytes)>" % self.needed_bytes
 
 class UncoordinatedWriteError(Exception):
     pass
@@ -372,7 +374,7 @@ class Retrieve:
             return
         if f.check(NeedMoreDataError):
             # 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
             self._do_query(conn, peerid, storage_index, self._read_size,
                            peer_storage_servers)
index 936e84a6ee158d91a832c83ae4349fedb4d74973..5ec8e11c5199740cda6152bbf59afa25d903d3cf 100644 (file)
@@ -181,7 +181,16 @@ def dump_SDMF_share(offset, length, config, out, err):
     data = f.read(min(length, 2000))
     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,
      pubkey, signature, share_hash_chain, block_hash_tree,