Some prefetch bug fixes

This commit is contained in:
Gavin John 2026-01-29 19:49:36 -08:00
parent 333a5cd066
commit 3692fecb54

View file

@ -21,7 +21,9 @@ async def nix_prefetch_zip(url: str) -> Tuple[str, Path]:
stdout, stderr = await proc.communicate()
if proc.returncode != 0:
raise RuntimeError(stderr.decode())
raise NurError(
f"Failed to prefetch git repository {url}: {stderr.decode()}"
)
sha256, path = stdout.decode().strip().split("\n")
return sha256, Path(path)
@ -41,7 +43,9 @@ class GitPrefetcher:
stdout, stderr = await proc.communicate()
if proc.returncode != 0:
raise RuntimeError(stderr.decode())
raise NurError(
f"Failed to prefetch git repository {self.repo.url.geturl()}: {stderr.decode()}"
)
return stdout.decode().split(maxsplit=1)[0]
@ -58,7 +62,7 @@ class GitPrefetcher:
stderr=asyncio.subprocess.PIPE,
)
try:
stdout, stderr = proc.communicate(timeout=30)
stdout, stderr = await asyncio.wait_for(proc.communicate(), 30)
except subprocess.TimeoutExpired:
proc.kill()
raise NurError(