Hard link serve panic fix (#2210)
* Fix hard link panic and add better error info to std:fs errors * cargo fmt * Remove erroneously committed config change * Remove console import; Use with context to provide additional error info * improve error wording
This commit is contained in:
parent
448a941f93
commit
0a9bfa16c2
@ -86,7 +86,12 @@ pub fn copy_file_if_needed(src: &Path, dest: &Path, hard_link: bool) -> Result<(
|
||||
}
|
||||
|
||||
if hard_link {
|
||||
std::fs::hard_link(src, dest)?
|
||||
if dest.exists() {
|
||||
std::fs::remove_file(dest)
|
||||
.with_context(|| format!("Error removing file: {:?}", dest))?;
|
||||
}
|
||||
std::fs::hard_link(src, dest)
|
||||
.with_context(|| format!("Error hard linking file, src: {:?}, dst: {:?}", src, dest))?;
|
||||
} else {
|
||||
let src_metadata = metadata(src)
|
||||
.with_context(|| format!("Failed to get metadata of {}", src.display()))?;
|
||||
|
Loading…
Reference in New Issue
Block a user