mutable: oops, .download *is* in use, by the speedtest. Restore it and add a test.

This commit is contained in:
Brian Warner 2008-03-04 15:11:40 -07:00
parent 4daa817502
commit 7d9bfbcabe
2 changed files with 14 additions and 1 deletions

View File

@ -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)

View File

@ -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