From 91bf312e4d96ff3d946333909243661a1b440b18 Mon Sep 17 00:00:00 2001 From: Lex Berezhny Date: Fri, 27 Jul 2018 21:35:01 -0400 Subject: [PATCH] fix for file open during publish --- lbrynet/core/file_utils.py | 17 ----------------- lbrynet/daemon/Publisher.py | 3 +-- 2 files changed, 1 insertion(+), 19 deletions(-) delete mode 100644 lbrynet/core/file_utils.py diff --git a/lbrynet/core/file_utils.py b/lbrynet/core/file_utils.py deleted file mode 100644 index 7ec9be280..000000000 --- a/lbrynet/core/file_utils.py +++ /dev/null @@ -1,17 +0,0 @@ -import os -from contextlib import contextmanager - - -@contextmanager -def get_read_handle(path): - """ - Get os independent read handle for a file - """ - - if os.name == "nt": - file_mode = 'rb' - else: - file_mode = 'r' - read_handle = open(path, file_mode) - yield read_handle - read_handle.close() diff --git a/lbrynet/daemon/Publisher.py b/lbrynet/daemon/Publisher.py index ee7045cfc..5c76ddb1d 100644 --- a/lbrynet/daemon/Publisher.py +++ b/lbrynet/daemon/Publisher.py @@ -5,7 +5,6 @@ from binascii import hexlify from twisted.internet import defer -from lbrynet.core import file_utils from lbrynet.file_manager.EncryptedFileCreator import create_lbry_file from lbrynet.wallet.account import get_certificate_lookup @@ -32,7 +31,7 @@ class Publisher: raise Exception("Cannot publish empty file {}".format(file_path)) file_name = os.path.basename(file_path) - with file_utils.get_read_handle(file_path) as read_handle: + with open(file_path, 'rb') as read_handle: self.lbry_file = yield create_lbry_file( self.blob_manager, self.storage, self.payment_rate_manager, self.lbry_file_manager, file_name, read_handle