From dab49e812f760b706bdc4ed7ce7a69ed68ed2698 Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Tue, 23 Apr 2019 14:25:47 -0400 Subject: [PATCH] set writer result or error before calling close_handle --- lbrynet/blob/writer.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lbrynet/blob/writer.py b/lbrynet/blob/writer.py index 914680b19..b4b2902a8 100644 --- a/lbrynet/blob/writer.py +++ b/lbrynet/blob/writer.py @@ -44,16 +44,15 @@ class HashBlobWriter: self._hashsum.update(data) self.len_so_far += len(data) if self.len_so_far > expected_length: - self.close_handle() self.finished.set_exception(InvalidDataError( f'Length so far is greater than the expected length. {self.len_so_far} to {expected_length}' )) + self.close_handle() return self.buffer.write(data) if self.len_so_far == expected_length: blob_hash = self.calculate_blob_hash() if blob_hash != self.expected_blob_hash: - self.close_handle() self.finished.set_exception(InvalidBlobHashError( f"blob hash is {blob_hash} vs expected {self.expected_blob_hash}" ))