remove MutableFileNode.download(), prefer download_best_version() instead

This commit is contained in:
Brian Warner 2009-12-01 17:54:38 -05:00
parent 96834da0a2
commit a980ea337b
2 changed files with 2 additions and 31 deletions

View 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):

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