From: Brian Warner Date: Thu, 17 Jan 2008 08:52:33 +0000 (-0700) Subject: offloaded: close the local filehandle after encoding is done, otherwise windows fails X-Git-Tag: allmydata-tahoe-0.8.0~295 X-Git-Url: https://git.rkrishnan.org/%5B/%5D%20/uri/index.php?a=commitdiff_plain;h=e9307d3fdafca2bc9087d2fd8b7fb3463f161558;p=tahoe-lafs%2Ftahoe-lafs.git offloaded: close the local filehandle after encoding is done, otherwise windows fails --- diff --git a/src/allmydata/encode.py b/src/allmydata/encode.py index 06c8e166..0d63a6fc 100644 --- a/src/allmydata/encode.py +++ b/src/allmydata/encode.py @@ -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): diff --git a/src/allmydata/interfaces.py b/src/allmydata/interfaces.py index c748a8f0..0bbd86c1 100644 --- a/src/allmydata/interfaces.py +++ b/src/allmydata/interfaces.py @@ -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" diff --git a/src/allmydata/offloaded.py b/src/allmydata/offloaded.py index d1f62ef9..9f1966c1 100644 --- a/src/allmydata/offloaded.py +++ b/src/allmydata/offloaded.py @@ -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") diff --git a/src/allmydata/upload.py b/src/allmydata/upload.py index 107d4c64..04880a8a 100644 --- a/src/allmydata/upload.py +++ b/src/allmydata/upload.py @@ -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: