add ispath, and file size check before publishing

This commit is contained in:
Kay Kurokawa 2017-05-29 14:41:15 -04:00
parent 8a2a8ce05f
commit 3c880a1684
2 changed files with 6 additions and 1 deletions

View file

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

View file

@ -24,6 +24,11 @@ class Publisher(object):
def create_and_publish_stream(self, name, bid, claim_dict, file_path):
"""Create lbry file and make claim"""
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)
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,