delete upon failing to decode JSON from sd blob

This commit is contained in:
Victor Shyba 2019-02-21 20:53:21 -03:00
parent edb5083a5e
commit fcdd9295b4

View file

@ -134,6 +134,7 @@ class StreamDescriptor:
try: try:
decoded = json.loads(json_bytes.decode()) decoded = json.loads(json_bytes.decode())
except json.JSONDecodeError: except json.JSONDecodeError:
blob.delete()
raise InvalidStreamDescriptorError("Does not decode as valid JSON") raise InvalidStreamDescriptorError("Does not decode as valid JSON")
if decoded['blobs'][-1]['length'] != 0: if decoded['blobs'][-1]['length'] != 0:
raise InvalidStreamDescriptorError("Does not end with a zero-length blob.") raise InvalidStreamDescriptorError("Does not end with a zero-length blob.")