Skip to content

Commit 33012b6

Browse files
committed
fix(cli/cache): 🐛 avoid stream=True when fetching remote crates
1 parent 392df1a commit 33012b6

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

rocrate_validator/cli/commands/cache.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121

2222
import copy as _copy
2323
import json
24-
import shutil
25-
import tempfile
2624
from datetime import datetime
2725
from pathlib import Path
2826
from typing import List, Optional
@@ -456,17 +454,16 @@ def _warm_remote_crates(urls: List[str]) -> List[WarmUpResult]:
456454
results: List[WarmUpResult] = []
457455
for url in urls:
458456
try:
459-
response = requester.fetch_fresh(url, stream=True, allow_redirects=True)
457+
response = requester.fetch_fresh(url, allow_redirects=True)
460458
status = getattr(response, "status_code", None)
461459
if status is None:
462460
results.append(WarmUpResult(url=url, status="failed", detail="no status code"))
463461
continue
464462
if status >= 400:
465463
results.append(WarmUpResult(url=url, status="failed", detail=f"HTTP {status}"))
466464
continue
467-
# Consume the response body so that the cache backend stores it.
468-
with tempfile.TemporaryFile() as tmp:
469-
shutil.copyfileobj(response.raw, tmp)
465+
# Touch the body so the cache backend stores the full response.
466+
_ = response.content
470467
results.append(WarmUpResult(url=url, status="ok", detail=f"HTTP {status}"))
471468
except Exception as e:
472469
logger.debug("Remote crate warm-up failed for %s: %s", url, e)

0 commit comments

Comments
 (0)