Downloads: Fortschritt alle 30 s im Log

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X48pE4bzjHej8w9HyZXCjb
This commit is contained in:
Claude
2026-10-22 08:37:21 +02:00
parent 53b7c24a81
commit 1dd39c08db
+5
View File
@@ -54,9 +54,14 @@ def download(url: str, dest: Path) -> None:
with httpx.stream("GET", url, follow_redirects=True, timeout=120, with httpx.stream("GET", url, follow_redirects=True, timeout=120,
headers={"User-Agent": C.USER_AGENT}) as r: headers={"User-Agent": C.USER_AGENT}) as r:
r.raise_for_status() r.raise_for_status()
total, done, t0, last = int(r.headers.get("content-length", 0)), 0, time.time(), time.time()
with open(tmp, "wb") as f: with open(tmp, "wb") as f:
for chunk in r.iter_bytes(1 << 20): for chunk in r.iter_bytes(1 << 20):
f.write(chunk) f.write(chunk)
done += len(chunk)
if time.time() - last > 30: # Fortschritt, damit ein langsamer Download nicht wie ein Hänger aussieht
last = time.time()
log.info(" … %d von %d MB (%.1f MB/s)", done >> 20, total >> 20, done / (last - t0) / 1e6)
tmp.rename(dest) tmp.rename(dest)