forked from LBRYCommunity/lbry-sdk
raise proper exception on undecode-able blobs
This commit is contained in:
parent
aa40337ded
commit
4e7d88311f
1 changed files with 4 additions and 1 deletions
|
@ -131,7 +131,10 @@ class StreamDescriptor:
|
|||
assert os.path.isfile(blob.file_path)
|
||||
with open(blob.file_path, 'rb') as f:
|
||||
json_bytes = f.read()
|
||||
decoded = json.loads(json_bytes.decode())
|
||||
try:
|
||||
decoded = json.loads(json_bytes.decode())
|
||||
except json.JSONDecodeError:
|
||||
raise InvalidStreamDescriptorError("Does not decode as valid JSON")
|
||||
if decoded['blobs'][-1]['length'] != 0:
|
||||
raise InvalidStreamDescriptorError("Does not end with a zero-length blob.")
|
||||
if any([blob_info['length'] == 0 for blob_info in decoded['blobs'][:-1]]):
|
||||
|
|
Loading…
Reference in a new issue