Skip to content

Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.

C++

setup: a download stopped before its rename is finished without asking for more

Akido5f6b7c27661f
diff --git a/setup.py b/setup.py
index a45d39e6e..8b26d858a 100644
--- a/setup.py
+++ b/setup.py
@@ -1066,6 +1066,8 @@ def download(url, dst: Path, what=None):
return
have = part.stat().st_size if part.exists() else 0
for attempt in range(30):
+ if total and have >= total: # stopped after the last byte, before the rename: nothing to
+ break # ask for (a range past the end is a 416, retried 30 times)
try:
req = urllib.request.Request(url, headers={"User-Agent": "strata-setup", "Range": f"bytes={have}-"})
with urllib.request.urlopen(req, timeout=60) as r, open(part, "ab" if have else "wb") as f:
diff --git a/tools/test_setup_pins.py b/tools/test_setup_pins.py
index 8638fdcfe..2d8a08af7 100644
--- a/tools/test_setup_pins.py
+++ b/tools/test_setup_pins.py
@@ -81,6 +81,26 @@ class HuggingFacePins(unittest.TestCase):
self.assertEqual([m for m, _ in seen], ["HEAD", "HEAD", "GET"])
self.assertTrue(all("/resolve/main/" in u for _, u in seen[1:]))
+ def test_a_complete_part_is_finished_without_a_request(self):
+ """A .part with every byte (setup stopped between the last byte and the rename): renamed, not resumed with a
+ range past its end - the server answers that with 416, which download() retried 30 times, 10 s apart."""
+ seen = []
+
+ def urlopen(req, timeout=None):
+ seen.append((req.get_method(), req.headers.get("Range")))
+ if req.get_method() == "HEAD":
+ return Response(b"model bytes")
+ raise urllib.error.HTTPError(req.full_url, 416, "Range Not Satisfiable", {}, None)
+
+ with tempfile.TemporaryDirectory() as d, mock.patch.object(setup.urllib.request, "urlopen", urlopen), \
+ mock.patch.object(setup.time, "sleep", lambda s: None):
+ dst = Path(d) / "m.gguf"
+ dst.with_name("m.gguf.part").write_bytes(b"model bytes")
+ quiet(setup.download, "https://example.com/m.gguf", dst)
+ self.assertEqual(dst.read_bytes(), b"model bytes")
+ self.assertTrue(setup.done(dst))
+ self.assertEqual(seen, [("HEAD", None)])
+
def test_mtp_fetch_is_pinned_and_falls_back(self):
import mtp_fetch
self.assertRegex(mtp_fetch.REPO, SHA)