Merge pull request #653 from lbryio/add_publish_filecheck

add ispath, and file size check before publishing
This commit is contained in:
Jack Robison 2017-05-30 11:39:56 -04:00 committed by GitHub
commit 73a5828865
2 changed files with 6 additions and 1 deletions

View file

@ -9,7 +9,7 @@ at anytime.
## [Unreleased] ## [Unreleased]
### Added ### Added
* * Prevent publish of files with size 0
* *
### Changed ### Changed

View file

@ -24,6 +24,11 @@ class Publisher(object):
def create_and_publish_stream(self, name, bid, claim_dict, file_path): def create_and_publish_stream(self, name, bid, claim_dict, file_path):
"""Create lbry file and make claim""" """Create lbry file and make claim"""
log.info('Starting publish for %s', name) log.info('Starting publish for %s', name)
if not os.path.isfile(file_path):
raise Exception("File {} not found".format(file_path))
if os.path.getsize(file_path) == 0:
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 file_utils.get_read_handle(file_path) as read_handle:
stream_hash = yield create_lbry_file(self.session, self.lbry_file_manager, file_name, stream_hash = yield create_lbry_file(self.session, self.lbry_file_manager, file_name,