Downloader: Gracefully handle '416 Range Not Satisfiable' when continuing downloads

This commit is contained in:
oobabooga 2025-10-09 10:52:31 -07:00
parent 0f3793d608
commit 1aa2b924d2

View file

@ -255,6 +255,11 @@ class ModelDownloader:
mode = 'ab'
with session.get(url, stream=True, headers=headers, timeout=30) as r:
# Assume error 416 (range unsatisfiable) means the download is complete.
# Small size differences can happen in Git LFS
if mode == 'ab' and r.status_code == 416:
break
r.raise_for_status()
total_size_from_stream = int(r.headers.get('content-length', 0))
if mode == 'ab':