From: Daira Hopwood <daira@jacaranda.org>
Date: Thu, 5 Sep 2013 16:46:33 +0000 (+0100)
Subject: Tue Jun 12 02:16:02 BST 2012  Brian Warner <warner@lothar.com>
X-Git-Url: https://git.rkrishnan.org/%5B/simplejson/$rel_link?a=commitdiff_plain;h=6922952c466ff289990b35298e381856bdb29de4;p=tahoe-lafs%2Ftahoe-lafs.git

Tue Jun 12 02:16:02 BST 2012  Brian Warner <warner@lothar.com>
  * offloaded.py: don't drop the Deferred

  There was one corner case (where the client disconnects at just the
  wrong time) that could have dropped a Deferred, leading to an Unhandled
  Error. Clean up the control flow to avoid this case.
---

diff --git a/src/allmydata/immutable/offloaded.py b/src/allmydata/immutable/offloaded.py
index 02b1386e..017dd2a4 100644
--- a/src/allmydata/immutable/offloaded.py
+++ b/src/allmydata/immutable/offloaded.py
@@ -311,14 +311,12 @@ class CHKCiphertextFetcher(AskUntilSuccessMixin):
             # else.
             have = os.stat(self._encoding_file)[stat.ST_SIZE]
             d = self.call("read_encrypted", have-1, 1)
-            d.addCallback(self._done2, started)
-            return
-
-        # first, find out how large the file is going to be
-        d = self.call("get_size")
-        d.addCallback(self._got_size)
-        d.addCallback(self._start_reading)
-        d.addCallback(self._done)
+        else:
+            # first, find out how large the file is going to be
+            d = self.call("get_size")
+            d.addCallback(self._got_size)
+            d.addCallback(self._start_reading)
+            d.addCallback(self._done)
         d.addCallback(self._done2, started)
         d.addErrback(self._failed)