]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
remove MutableFileNode.download(), prefer download_best_version() instead
authorBrian Warner <warner@lothar.com>
Tue, 1 Dec 2009 22:54:38 +0000 (17:54 -0500)
committerBrian Warner <warner@lothar.com>
Tue, 1 Dec 2009 22:54:38 +0000 (17:54 -0500)
src/allmydata/mutable/filenode.py
src/allmydata/test/common.py

index 4e531b9668d23b0cb956bed600dd4c2e941eede3..f8e12b5fc088e67bde6b7ce0f3f405bcc49df686 100644 (file)
@@ -278,21 +278,6 @@ class MutableFileNode:
     #################################
     # IMutableFileNode
 
-    # allow the use of IDownloadTarget
-    def download(self, target):
-        # fake it. TODO: make this cleaner.
-        d = self.download_best_version()
-        def _done(data):
-            target.open(len(data))
-            target.write(data)
-            target.close()
-            return target.finish()
-        d.addCallback(_done)
-        return d
-
-
-    # new API
-
     def download_best_version(self):
         return self._do_serialized(self._download_best_version)
     def _download_best_version(self):
index 7113ccebf576d4246a289e7663abfd3de82d6e25..ef2f6795f1415a3052edc1d10757205e7dcdfaac 100644 (file)
@@ -270,6 +270,8 @@ class FakeMutableFileNode:
         return d
 
     def download_best_version(self):
+        if self.storage_index not in self.all_contents:
+            return defer.fail(NotEnoughSharesError(None, 0, 3))
         return defer.succeed(self.all_contents[self.storage_index])
     def overwrite(self, new_contents):
         if len(new_contents) > self.MUTABLE_SIZELIMIT:
@@ -288,22 +290,6 @@ class FakeMutableFileNode:
         self.all_contents[self.storage_index] = modifier(old_contents, None, True)
         return None
 
-    def download(self, target):
-        if self.storage_index not in self.all_contents:
-            f = failure.Failure(NotEnoughSharesError(None, 0, 3))
-            target.fail(f)
-            return defer.fail(f)
-        data = self.all_contents[self.storage_index]
-        target.open(len(data))
-        target.write(data)
-        target.close()
-        return defer.maybeDeferred(target.finish)
-    def download_to_data(self):
-        if self.storage_index not in self.all_contents:
-            return defer.fail(NotEnoughSharesError(None, 0, 3))
-        data = self.all_contents[self.storage_index]
-        return defer.succeed(data)
-
 def make_mutable_file_cap():
     return uri.WriteableSSKFileURI(writekey=os.urandom(16),
                                    fingerprint=os.urandom(32))