From 7d9bfbcabe7393d3a8ed86c66fb553b26085b9c8 Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Tue, 4 Mar 2008 15:11:40 -0700 Subject: [PATCH] mutable: oops, .download *is* in use, by the speedtest. Restore it and add a test. --- src/allmydata/mutable.py | 11 +++++++++++ src/allmydata/test/test_mutable.py | 4 +++- 2 files changed, 14 insertions(+), 1 deletion(-) 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 -- 2.45.2