From c211d87164551c7cf46ef7ef120999eb89a6f5ff Mon Sep 17 00:00:00 2001 From: Job Evers-Meltzer Date: Sat, 21 Jan 2017 17:27:19 -0600 Subject: [PATCH] Bug fix: delete empty blobs When creating a CryptStream, the last blob is always empty. Previously, this blob wouldn't be deleted and would instead just stick around in the blobfiles directory. --- lbrynet/core/HashBlob.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/lbrynet/core/HashBlob.py b/lbrynet/core/HashBlob.py index af7dca563..929d5637e 100644 --- a/lbrynet/core/HashBlob.py +++ b/lbrynet/core/HashBlob.py @@ -392,16 +392,11 @@ class BlobFileCreator(HashBlobCreator): def _close(self): temp_file_name = self.out_file.name self.out_file.close() - - def change_file_name(): - shutil.move(temp_file_name, os.path.join(self.blob_dir, self.blob_hash)) - return True - if self.blob_hash is not None: - d = threads.deferToThread(change_file_name) + shutil.move(temp_file_name, os.path.join(self.blob_dir, self.blob_hash)) else: - d = defer.succeed(True) - return d + os.remove(temp_file_name) + return defer.succeed(True) def _write(self, data): self.out_file.write(data)