fix(core): error when restoring http cache with no outputs (#30961)
This commit is contained in:
parent
cf81286421
commit
91f5249fbf
31
packages/nx/src/native/cache/cache.rs
vendored
31
packages/nx/src/native/cache/cache.rs
vendored
@ -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
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user