From: Brian Warner Date: Wed, 16 Jul 2008 23:31:47 +0000 (-0700) Subject: immutable download: remove dead LiteralDownloader, now that we use filenodes for... X-Git-Url: https://git.rkrishnan.org/simplejson/%22news.html/configuration.txt?a=commitdiff_plain;h=7b9fff388d8c662fdfc8afc88a05aebd518496b4;p=tahoe-lafs%2Ftahoe-lafs.git immutable download: remove dead LiteralDownloader, now that we use filenodes for download --- diff --git a/src/allmydata/immutable/download.py b/src/allmydata/immutable/download.py index 983575ed..975a7169 100644 --- a/src/allmydata/immutable/download.py +++ b/src/allmydata/immutable/download.py @@ -955,29 +955,6 @@ class FileDownloader: return self._status -class LiteralDownloader: - def __init__(self, client, u, downloadable): - self._uri = IFileURI(u) - assert isinstance(self._uri, uri.LiteralFileURI) - self._downloadable = downloadable - self._status = s = DownloadStatus() - s.set_storage_index(None) - s.set_helper(False) - s.set_status("Done") - s.set_active(False) - s.set_progress(1.0) - - def start(self): - data = self._uri.data - self._status.set_size(len(data)) - self._downloadable.open(len(data)) - self._downloadable.write(data) - self._downloadable.close() - return defer.maybeDeferred(self._downloadable.finish) - - def get_download_status(self): - return self._status - class FileName: implements(IDownloadTarget) def __init__(self, filename): @@ -1044,6 +1021,8 @@ class FileHandle: class Downloader(service.MultiService): """I am a service that allows file downloading. """ + # TODO: in fact, this service only downloads immutable files (URI:CHK:). + # It is scheduled to go away, to be replaced by filenode.download() implements(IDownloader) name = "downloader" MAX_DOWNLOAD_STATUSES = 10 @@ -1063,18 +1042,13 @@ class Downloader(service.MultiService): assert t.write assert t.close - - if isinstance(u, uri.LiteralFileURI): - dl = LiteralDownloader(self.parent, u, t) - elif isinstance(u, uri.CHKFileURI): - if self.stats_provider: - # these counters are meant for network traffic, and don't - # include LIT files - self.stats_provider.count('downloader.files_downloaded', 1) - self.stats_provider.count('downloader.bytes_downloaded', u.get_size()) - dl = FileDownloader(self.parent, u, t) - else: - raise RuntimeError("I don't know how to download a %s" % u) + assert isinstance(u, uri.CHKFileURI) + if self.stats_provider: + # these counters are meant for network traffic, and don't + # include LIT files + self.stats_provider.count('downloader.files_downloaded', 1) + self.stats_provider.count('downloader.bytes_downloaded', u.get_size()) + dl = FileDownloader(self.parent, u, t) self._add_download(dl) d = dl.start() return d