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:
@@ -54,9 +54,14 @@ def download(url: str, dest: Path) -> None:
|
||||
with httpx.stream("GET", url, follow_redirects=True, timeout=120,
|
||||
headers={"User-Agent": C.USER_AGENT}) as r:
|
||||
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:
|
||||
for chunk in r.iter_bytes(1 << 20):
|
||||
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)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user