mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-02-20 17:52:50 +00:00
Raise NotEnoughSharesError if there are initially not enough shares for a mutable retrieve. refs #1742
We also change the order of setting up attributes in Retrieve so that _raise_notenoughshareserror() can be called from _setup_download. Signed-off-by: Daira Hopwood <david-sarah@jacaranda.org>
This commit is contained in:
parent
a74b09ec86
commit
cf52c512c5
@ -241,8 +241,8 @@ class Retrieve:
|
||||
self._done_deferred = defer.Deferred()
|
||||
self._offset = offset
|
||||
self._read_length = size
|
||||
self._setup_download()
|
||||
self._setup_encoding_parameters()
|
||||
self._setup_download()
|
||||
self.log("starting download")
|
||||
self._started_fetching = time.time()
|
||||
# The download process beyond this is a state machine.
|
||||
@ -296,12 +296,18 @@ class Retrieve:
|
||||
self._storage_index, shnum, None)
|
||||
reader.server = server
|
||||
self.readers[shnum] = reader
|
||||
assert len(self.remaining_sharemap) >= k
|
||||
|
||||
if len(self.remaining_sharemap) < k:
|
||||
self._raise_notenoughshareserror()
|
||||
|
||||
self.shares = {} # maps shnum to validated blocks
|
||||
self._active_readers = [] # list of active readers for this dl.
|
||||
self._block_hash_trees = {} # shnum => hashtree
|
||||
|
||||
for i in xrange(self._total_shares):
|
||||
# So we don't have to do this later.
|
||||
self._block_hash_trees[i] = hashtree.IncompleteHashTree(self._num_segments)
|
||||
|
||||
# We need one share hash tree for the entire file; its leaves
|
||||
# are the roots of the block hash trees for the shares that
|
||||
# comprise it, and its root is in the verinfo.
|
||||
@ -317,8 +323,6 @@ class Retrieve:
|
||||
segment with. I return the plaintext associated with that
|
||||
segment.
|
||||
"""
|
||||
# shnum => block hash tree. Unused, but setup_encoding_parameters will
|
||||
# want to set this.
|
||||
self._block_hash_trees = None
|
||||
self._setup_encoding_parameters()
|
||||
|
||||
@ -384,11 +388,6 @@ class Retrieve:
|
||||
(k, n, self._num_segments, self._segment_size,
|
||||
self._tail_segment_size))
|
||||
|
||||
if self._block_hash_trees is not None:
|
||||
for i in xrange(self._total_shares):
|
||||
# So we don't have to do this later.
|
||||
self._block_hash_trees[i] = hashtree.IncompleteHashTree(self._num_segments)
|
||||
|
||||
# Our last task is to tell the downloader where to start and
|
||||
# where to stop. We use three parameters for that:
|
||||
# - self._start_segment: the segment that we need to start
|
||||
|
Loading…
x
Reference in New Issue
Block a user