From: Brian Warner Date: Tue, 4 Mar 2008 22:11:40 +0000 (-0700) Subject: mutable: oops, .download *is* in use, by the speedtest. Restore it and add a test. X-Git-Tag: allmydata-tahoe-0.9.0~71 X-Git-Url: https://git.rkrishnan.org/Site/Content/Exhibitors/nxhtml.html?a=commitdiff_plain;h=7d9bfbcabe7393d3a8ed86c66fb553b26085b9c8;p=tahoe-lafs%2Ftahoe-lafs.git mutable: oops, .download *is* in use, by the speedtest. Restore it and add a test. --- diff --git a/src/allmydata/mutable.py b/src/allmydata/mutable.py index 713c5bf7..925a286a 100644 --- a/src/allmydata/mutable.py +++ b/src/allmydata/mutable.py @@ -1595,6 +1595,17 @@ class MutableFileNode: verifier = self.get_verifier() return self._client.getServiceNamed("checker").check(verifier) + def download(self, target): + # fake it. TODO: make this cleaner. + d = self.download_to_data() + def _done(data): + target.open(len(data)) + target.write(data) + target.close() + return target.finish() + d.addCallback(_done) + return d + def download_to_data(self): r = self.retrieve_class(self) self._client.notify_retrieve(r) diff --git a/src/allmydata/test/test_mutable.py b/src/allmydata/test/test_mutable.py index 0d3460f5..bc640366 100644 --- a/src/allmydata/test/test_mutable.py +++ b/src/allmydata/test/test_mutable.py @@ -3,7 +3,7 @@ import itertools, struct from twisted.trial import unittest from twisted.internet import defer from twisted.python import failure, log -from allmydata import mutable, uri, dirnode +from allmydata import mutable, uri, dirnode, download from allmydata.util.hashutil import tagged_hash from allmydata.encode import NotEnoughPeersError from allmydata.interfaces import IURI, INewDirectoryURI, \ @@ -154,6 +154,8 @@ class Filenode(unittest.TestCase): d.addCallback(lambda res: n.replace("contents 2")) d.addCallback(lambda res: n.download_to_data()) d.addCallback(lambda res: self.failUnlessEqual(res, "contents 2")) + d.addCallback(lambda res: n.download(download.Data())) + d.addCallback(lambda res: self.failUnlessEqual(res, "contents 2")) return d d.addCallback(_created) return d