From 8ef090a6d5fb687194dd3ac57457d927c98b4e02 Mon Sep 17 00:00:00 2001 From: 3dalgolab Date: Sun, 26 Oct 2025 09:34:40 +0900 Subject: [PATCH] Fix download function to handle zero remote size case --- dspy/utils/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dspy/utils/__init__.py b/dspy/utils/__init__.py index 8f5e9cf5e5..93965dbfc3 100644 --- a/dspy/utils/__init__.py +++ b/dspy/utils/__init__.py @@ -16,7 +16,7 @@ def download(url): remote_size = int(requests.head(url, allow_redirects=True).headers.get("Content-Length", 0)) local_size = os.path.getsize(filename) if os.path.exists(filename) else 0 - if local_size != remote_size: + if local_size != remote_size or remote_size == 0: print(f"Downloading '{filename}'...") with requests.get(url, stream=True) as r, open(filename, "wb") as f: for chunk in r.iter_content(chunk_size=8192):