fix(core): error when restoring http cache with no outputs (#30961)

This commit is contained in:
Craigory Coppola 2025-04-30 20:19:45 -04:00 committed by GitHub
parent cf81286421
commit 91f5249fbf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -301,9 +301,26 @@ impl NxCache {
&outputs_path,
&self.workspace_root
);
let sz = _copy(outputs_path, &self.workspace_root)?;
let sz = _copy(outputs_path, &self.workspace_root);
Ok(sz)
match sz {
Err(e) => {
let kind = underlying_io_error_kind(&e);
match kind {
Some(std::io::ErrorKind::NotFound) => {
trace!("No artifacts to copy: {:?}", e);
Ok(0)
}
_ => {
return Err(anyhow::anyhow!("Error copying files from cache: {:?}", e));
}
}
}
Ok(sz) => {
trace!("Copied {} bytes from cache", sz);
Ok(sz)
}
}
}
#[napi]
@ -407,3 +424,13 @@ where
}
}
}
// From: https://docs.rs/anyhow/latest/anyhow/struct.Error.html#example-1
fn underlying_io_error_kind(error: &anyhow::Error) -> Option<std::io::ErrorKind> {
for cause in error.chain() {
if let Some(io_error) = cause.downcast_ref::<std::io::Error>() {
return Some(io_error.kind());
}
}
None
}