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)
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, \
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