Skip to content

Commit

Permalink
fix: attempt copying trampoline when hard-linking fails (#2464)
Browse files Browse the repository at this point in the history
Fixes #2462
  • Loading branch information
Hofer-Julian authored Nov 12, 2024
1 parent 5d37dcf commit 5ad9312
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/global/trampoline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,9 +354,15 @@ impl Trampoline {
.into_diagnostic()?;
}

// Create a hard link to the shared trampoline binary
if !self.path().exists() {
tokio::fs::hard_link(self.trampoline_path(), self.path())
// If the path doesn't exist yet, create a hard link to the shared trampoline binary
// If creating a hard link doesn't succeed, try copying
// Hard-linking might for example fail because the file-system enforces a maximum number of hard-links per file
if !self.path().exists()
&& tokio_fs::hard_link(self.trampoline_path(), self.path())
.await
.is_err()
{
tokio_fs::copy(self.trampoline_path(), self.path())
.await
.into_diagnostic()?;
}
Expand Down

0 comments on commit 5ad9312

Please sign in to comment.