offloaded: close the local filehandle after encoding is done, otherwise windows fails

This commit is contained in:
Brian Warner 2008-01-17 01:52:33 -07:00
parent fd0dc3013c
commit e9307d3fda
4 changed files with 14 additions and 5 deletions

View File

@ -448,12 +448,10 @@ class Encoder(object):
def finish_hashing(self):
crypttext_hash = self._crypttext_hasher.digest()
self.uri_extension_data["crypttext_hash"] = crypttext_hash
u = self._uploadable
d = u.get_plaintext_hash()
d = self._uploadable.get_plaintext_hash()
def _got(plaintext_hash):
self.uri_extension_data["plaintext_hash"] = plaintext_hash
return u.get_plaintext_hashtree_leaves(0, self.num_segments,
self.num_segments)
return self._uploadable.get_plaintext_hashtree_leaves(0, self.num_segments, self.num_segments)
d.addCallback(_got)
def _got_hashtree_leaves(leaves):
self.log("Encoder: got plaintext_hashtree_leaves: %s" %
@ -462,6 +460,8 @@ class Encoder(object):
self.uri_extension_data["plaintext_root_hash"] = ht[0]
self._plaintext_hashtree_nodes = ht
d.addCallback(_got_hashtree_leaves)
d.addCallback(lambda res: self._uploadable.close())
return d
def send_plaintext_hash_tree_to_all_shareholders(self):

View File

@ -1282,6 +1282,9 @@ class RIEncryptedUploadable(RemoteInterface):
def get_plaintext_hash():
return Hash
def close():
return None
class RICHKUploadHelper(RemoteInterface):
__remote_name__ = "RIUploadHelper.tahoe.allmydata.com"

View File

@ -295,7 +295,8 @@ class LocalCiphertextReader(AskUntilSuccessMixin):
def get_plaintext_hash(self):
return self.call("get_plaintext_hash")
def close(self):
# ??
self.f.close()
# ??. I'm not sure if it makes sense to forward the close message.
return self.call("close")

View File

@ -498,6 +498,9 @@ class EncryptAnUploadable:
h = self._plaintext_hasher.digest()
return defer.succeed(h)
def close(self):
return self.original.close()
class CHKUploader:
peer_selector_class = Tahoe2PeerSelector
@ -687,6 +690,8 @@ class RemoteEncryptedUploadable(Referenceable):
return d
def remote_get_plaintext_hash(self):
return self._eu.get_plaintext_hash()
def remote_close(self):
return self._eu.close()
class AssistedUploader: