fix(core): error when restoring http cache with no outputs (#30961)
This commit is contained in:
parent
cf81286421
commit
91f5249fbf
29
packages/nx/src/native/cache/cache.rs
vendored
29
packages/nx/src/native/cache/cache.rs
vendored
@ -301,10 +301,27 @@ impl NxCache {
|
|||||||
&outputs_path,
|
&outputs_path,
|
||||||
&self.workspace_root
|
&self.workspace_root
|
||||||
);
|
);
|
||||||
let sz = _copy(outputs_path, &self.workspace_root)?;
|
let sz = _copy(outputs_path, &self.workspace_root);
|
||||||
|
|
||||||
|
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)
|
Ok(sz)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[napi]
|
#[napi]
|
||||||
pub fn remove_old_cache_records(&self) -> anyhow::Result<()> {
|
pub fn remove_old_cache_records(&self) -> anyhow::Result<()> {
|
||||||
@ -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