Simplify immutable download API: use just filenode.read(consumer, offset, size)

* remove Downloader.download_to_data/download_to_filename/download_to_filehandle
* remove download.Data/FileName/FileHandle targets
* remove filenode.download/download_to_data/download_to_filename methods
* leave Downloader.download (the whole Downloader will go away eventually)
* add util.consumer.MemoryConsumer/download_to_data, for convenience
  (this is mostly used by unit tests, but it gets used by enough non-test
   code to warrant putting it in allmydata.util)
* update tests
* removes about 180 lines of code. Yay negative code days!

Overall plan is to rewrite immutable/download.py and leave filenode.read() as
the sole read-side API.
This commit is contained in:
Brian Warner
2009-12-01 17:44:35 -05:00
parent 1059db51f2
commit 96834da0a2
18 changed files with 165 additions and 350 deletions

View File

@ -18,6 +18,7 @@ from allmydata.monitor import Monitor
from allmydata.util import hashutil, mathutil, base32, log
from allmydata.util.assertutil import precondition
from allmydata.util.netstring import netstring, split_netstring
from allmydata.util.consumer import download_to_data
from allmydata.uri import LiteralFileURI, from_string, wrap_dirnode_cap
from pycryptopp.cipher.aes import AES
from allmydata.util.dictutil import AuxValueDict
@ -217,7 +218,7 @@ class DirectoryNode:
# use the IMutableFileNode API.
d = self._node.download_best_version()
else:
d = self._node.download_to_data()
d = download_to_data(self._node)
d.addCallback(self._unpack_contents)
return d