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 5, 2023
1 parent defd3eb commit f95b4f5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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
12 changes: 4 additions & 8 deletions components/utils/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,11 @@ 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(|| format!("Error removing file, dst: {:?}", dest))?;
}
std::fs::hard_link(src, dest)
.with_context(|| format!("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 f95b4f5

Please sign in to comment.