[utils] Add try_call

This commit is contained in:
pukkandan 2022-03-31 13:19:16 +05:30
parent f189faf1ce
commit c4f60dd7cd
No known key found for this signature in database
GPG key ID: 7EEE9E1E817D0A39
5 changed files with 25 additions and 19 deletions

View file

@ -18,7 +18,7 @@ from ..utils import (
parse_http_range,
sanitized_Request,
ThrottledDownload,
try_get,
try_call,
write_xattr,
XAttrMetadataError,
XAttrUnavailableError,
@ -120,12 +120,12 @@ class HttpFD(FileDownloader):
else:
range_end = None
if try_get(None, lambda _: range_start > range_end):
if try_call(lambda: range_start > range_end):
ctx.resume_len = 0
ctx.open_mode = 'wb'
raise RetryDownload(Exception(f'Conflicting range. (start={range_start} > end={range_end})'))
if try_get(None, lambda _: range_end >= ctx.content_len):
if try_call(lambda: range_end >= ctx.content_len):
range_end = ctx.content_len - 1
request = sanitized_Request(url, request_data, headers)