From 1848091b77367fe4123e91de0fa36054767f6a3d Mon Sep 17 00:00:00 2001 From: Andrew Langmeier Date: Thu, 4 May 2023 18:51:59 -0400 Subject: [PATCH] Remove console import; Use with context to provide additional error info --- components/utils/Cargo.toml | 1 - components/utils/src/fs.rs | 10 ++-------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/components/utils/Cargo.toml b/components/utils/Cargo.toml index ee10a0fd91..65c4513381 100644 --- a/components/utils/Cargo.toml +++ b/components/utils/Cargo.toml @@ -8,7 +8,6 @@ include = ["src/**/*"] [dependencies] serde = { version = "1.0", features = ["derive"] } -console = { path = "../console" } errors = { path = "../errors" } libs = { path = "../libs" } diff --git a/components/utils/src/fs.rs b/components/utils/src/fs.rs index 1edc113670..01478983f2 100644 --- a/components/utils/src/fs.rs +++ b/components/utils/src/fs.rs @@ -87,15 +87,9 @@ pub fn copy_file_if_needed(src: &Path, dest: &Path, hard_link: bool) -> Result<( if hard_link { if dest.exists() { - if let Err(e) = std::fs::remove_file(dest) { - console::error(&format!("File System Error, src: {:?}, dst: {:?}", src, dest)); - return Err(e.into()); - } - } - if let Err(e) = std::fs::hard_link(src, dest) { - console::error(&format!("File System Error, src: {:?}, dst: {:?}", src, dest)); - return Err(e.into()); + std::fs::remove_file(dest).with_context(|| "Error removing file, dst: {:?}", dest)?; } + std::fs::hard_link(src, dest).with_context(|| "Error linking file, src: {:?}, dst: {:?}", src, dest)?; } else { let src_metadata = metadata(src) .with_context(|| format!("Failed to get metadata of {}", src.display()))?;