Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hard link serve panic fix #2210

Merged
merged 5 commits into from
May 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion components/utils/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()))?;
Expand Down