fix for file open during publish

This commit is contained in:
Lex Berezhny 2018-07-27 21:35:01 -04:00 committed by Jack Robison
parent 277b8b122c
commit 91bf312e4d
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2
2 changed files with 1 additions and 19 deletions

View file

@ -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()

View file

@ -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