fix for file open during publish
This commit is contained in:
parent
277b8b122c
commit
91bf312e4d
2 changed files with 1 additions and 19 deletions
|
@ -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()
|
|
|
@ -5,7 +5,6 @@ from binascii import hexlify
|
||||||
|
|
||||||
from twisted.internet import defer
|
from twisted.internet import defer
|
||||||
|
|
||||||
from lbrynet.core import file_utils
|
|
||||||
from lbrynet.file_manager.EncryptedFileCreator import create_lbry_file
|
from lbrynet.file_manager.EncryptedFileCreator import create_lbry_file
|
||||||
from lbrynet.wallet.account import get_certificate_lookup
|
from lbrynet.wallet.account import get_certificate_lookup
|
||||||
|
|
||||||
|
@ -32,7 +31,7 @@ class Publisher:
|
||||||
raise Exception("Cannot publish empty file {}".format(file_path))
|
raise Exception("Cannot publish empty file {}".format(file_path))
|
||||||
|
|
||||||
file_name = os.path.basename(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.lbry_file = yield create_lbry_file(
|
||||||
self.blob_manager, self.storage, self.payment_rate_manager, self.lbry_file_manager, file_name,
|
self.blob_manager, self.storage, self.payment_rate_manager, self.lbry_file_manager, file_name,
|
||||||
read_handle
|
read_handle
|
||||||
|
|
Loading…
Reference in a new issue