if history:
history.add_download(ds)
download_status = ds
- self._node = DownloadNode(verifycap, storage_broker, secret_holder,
- terminator, history, download_status)
+ self._terminator = terminator
+ self._history = history
+ self._download_status = download_status
+ self._node = None # created lazily, on read()
+
+ def _maybe_create_download_node(self):
+ if self._node is None:
+ self._node = DownloadNode(self._verifycap, self._storage_broker,
+ self._secret_holder,
+ self._terminator,
+ self._history, self._download_status)
def read(self, consumer, offset=0, size=None, read_ev=None):
"""I am the main entry point, from which FileNode.read() can get
data. I feed the consumer with the desired range of ciphertext. I
return a Deferred that fires (with the consumer) when the read is
finished."""
+ self._maybe_create_download_node()
return self._node.read(consumer, offset, size, read_ev)
def get_segment(self, segnum):
segment, so that you can call get_segment() before knowing the
segment size, and still know which data you received.
"""
+ self._maybe_create_download_node()
return self._node.get_segment(segnum)
def get_segment_size(self):
# return a Deferred that fires with the file's real segment size
+ self._maybe_create_download_node()
return self._node.get_segsize()
def get_storage_index(self):
self.c0 = self.g.clients[0]
self.load_shares()
n = self.c0.create_node_from_uri(immutable_uri)
+ n._cnode._maybe_create_download_node()
# Cause the downloader to guess a segsize that's too low, so it will
# ask for a segment number that's too high (beyond the end of the
d = self.c0.upload(u)
def _uploaded(ur):
n = self.c0.create_node_from_uri(ur.uri)
+ n._cnode._maybe_create_download_node()
n._cnode._node._build_guessed_tables(u.max_segment_size)
d1 = n.read(con1, 70, 20)
#d2 = n.read(con2, 140, 20) # XXX
d = self.c0.upload(u)
def _uploaded(ur):
n = self.c0.create_node_from_uri(ur.uri)
+ n._cnode._maybe_create_download_node()
n._cnode._node._build_guessed_tables(u.max_segment_size)
d = n.read(con1, 12000, 20)
def _read1(ign):
d = self.c0.upload(u)
def _uploaded(ur):
n = self.c0.create_node_from_uri(ur.uri)
+ n._cnode._maybe_create_download_node()
n._cnode._node._build_guessed_tables(u.max_segment_size)
d = download_to_data(n)
d = self.c0.upload(u)
def _uploaded(ur):
n = self.c0.create_node_from_uri(ur.uri)
+ n._cnode._maybe_create_download_node()
n._cnode._node._build_guessed_tables(u.max_segment_size)
d1 = n.read(con1, 70, 20)
#d2 = n.read(con2, 140, 20)
def _download(ign, imm_uri, which, expected):
n = self.c0.create_node_from_uri(imm_uri)
+ n._cnode._maybe_create_download_node()
# for this test to work, we need to have a new Node each time.
# Make sure the NodeMaker's weakcache hasn't interfered.
assert not n._cnode._node._shares
]
def _download(imm_uri):
n = self.c0.create_node_from_uri(imm_uri)
+ n._cnode._maybe_create_download_node()
# for this test to work, we need to have a new Node each time.
# Make sure the NodeMaker's weakcache hasn't interfered.
assert not n._cnode._node._shares