From 2d91b9845621639c53dca7ee9d3d954f3624ba18 Mon Sep 17 00:00:00 2001 From: Peter Hosey Date: Sun, 10 Mar 2024 08:35:20 -0700 Subject: [PATCH] [fd/http] Reset resume length to handle `FileNotFoundError` (#8399) Closes #4521 Authored by: boredzo --- yt_dlp/downloader/http.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/yt_dlp/downloader/http.py b/yt_dlp/downloader/http.py index f5237443e..693828b6e 100644 --- a/yt_dlp/downloader/http.py +++ b/yt_dlp/downloader/http.py @@ -237,8 +237,13 @@ def download(): 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: