diff --git a/packages/nx/src/native/cache/cache.rs b/packages/nx/src/native/cache/cache.rs index 18e53cf9deb3da..e995ab154095da 100644 --- a/packages/nx/src/native/cache/cache.rs +++ b/packages/nx/src/native/cache/cache.rs @@ -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 { + for cause in error.chain() { + if let Some(io_error) = cause.downcast_ref::() { + return Some(io_error.kind()); + } + } + None +}