[fragment] Ensure the file is closed on error

This commit is contained in:
pukkandan 2021-05-04 21:07:43 +05:30
parent 06425e9621
commit 6ef6bcbd6b
No known key found for this signature in database
GPG key ID: 0F00D95A001F4698
2 changed files with 6 additions and 0 deletions

View file

@ -113,6 +113,7 @@ def download_fragment(fragment):
if count > fragment_retries:
if not fatal:
return False, frag_index
ctx['dest_stream'].close()
self.report_error('Giving up after %s fragment retries' % fragment_retries)
return False, frag_index
@ -135,6 +136,7 @@ def append_fragment(frag_content, frag_index):
self.report_skip_fragment(frag_index)
return True
else:
ctx['dest_stream'].close()
self.report_error(
'fragment %s not found, unable to continue' % frag_index)
return False
@ -143,6 +145,7 @@ def append_fragment(frag_content, frag_index):
self.report_skip_fragment(frag_index)
return True
else:
ctx['dest_stream'].close()
self.report_error(
'fragment %s not found, unable to continue' % frag_index)
return False

View file

@ -299,6 +299,7 @@ def download_fragment(fragment):
if count <= fragment_retries:
self.report_retry_fragment(err, frag_index, count, fragment_retries)
if count > fragment_retries:
ctx['dest_stream'].close()
self.report_error('Giving up after %s fragment retries' % fragment_retries)
return False, frag_index
@ -403,6 +404,7 @@ def append_fragment(frag_content, frag_index):
self.report_skip_fragment(frag_index)
return True
else:
ctx['dest_stream'].close()
self.report_error(
'fragment %s not found, unable to continue' % frag_index)
return False
@ -411,6 +413,7 @@ def append_fragment(frag_content, frag_index):
self.report_skip_fragment(frag_index)
return True
else:
ctx['dest_stream'].close()
self.report_error(
'fragment %s not found, unable to continue' % frag_index)
return False