Skip to content

Commit

Permalink
Remove console import; Use with context to provide additional error info
Browse files Browse the repository at this point in the history
  • Loading branch information
Raymi306 committed May 4, 2023
1 parent defd3eb commit 1848091
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
1 change: 0 additions & 1 deletion components/utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ include = ["src/**/*"]
[dependencies]
serde = { version = "1.0", features = ["derive"] }

console = { path = "../console" }
errors = { path = "../errors" }
libs = { path = "../libs" }

Expand Down
10 changes: 2 additions & 8 deletions components/utils/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()))?;
Expand Down

0 comments on commit 1848091

Please sign in to comment.