Accept full-file responses for small ModelScope objects
Browse files- mirror_worker.py +4 -1
mirror_worker.py
CHANGED
|
@@ -101,7 +101,10 @@ def direct_download(path: str, target: Path, size: int, expected_sha256: str | N
|
|
| 101 |
try:
|
| 102 |
headers = {"Range": f"bytes={start}-{end}"}
|
| 103 |
with client.stream("GET", url, headers=headers) as response:
|
| 104 |
-
|
|
|
|
|
|
|
|
|
|
| 105 |
raise RuntimeError(f"range {start}-{end}: HTTP {response.status_code}")
|
| 106 |
offset = start
|
| 107 |
for chunk in response.iter_bytes(4 * 1024 * 1024):
|
|
|
|
| 101 |
try:
|
| 102 |
headers = {"Range": f"bytes={start}-{end}"}
|
| 103 |
with client.stream("GET", url, headers=headers) as response:
|
| 104 |
+
full_file_response = start == 0 and end == size - 1
|
| 105 |
+
if response.status_code != 206 and not (
|
| 106 |
+
response.status_code == 200 and full_file_response
|
| 107 |
+
):
|
| 108 |
raise RuntimeError(f"range {start}-{end}: HTTP {response.status_code}")
|
| 109 |
offset = start
|
| 110 |
for chunk in response.iter_bytes(4 * 1024 * 1024):
|