[fd/http] Reset resume length to handle `FileNotFoundError` (#8399)

Closes #4521
Authored by: boredzo
This commit is contained in:
Peter Hosey 2024-03-10 08:35:20 -07:00 committed by GitHub
parent 8828f4576b
commit 2d91b98456
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 2 deletions

View File

@ -237,8 +237,13 @@ class HttpFD(FileDownloader):
def retry(e):
close_stream()
ctx.resume_len = (byte_counter if ctx.tmpfilename == '-'
else os.path.getsize(encodeFilename(ctx.tmpfilename)))
if ctx.tmpfilename == '-':
ctx.resume_len = byte_counter
else:
try:
ctx.resume_len = os.path.getsize(encodeFilename(ctx.tmpfilename))
except FileNotFoundError:
ctx.resume_len = 0
raise RetryDownload(e)
while True: