Skip to content

Commit

Permalink
Fix cross-device link error when running self-update on Linux (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
paradoxuum authored Aug 9, 2024
1 parent 4bd5aa6 commit 5ef1fc4
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lib/storage/tool_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,16 @@ impl ToolStorage {
let was_rokit_updated = if existing_rokit_binary == rokit_contents {
false
} else {
// NOTE: If the currently running Rokit binary is being updated,
// we need to move it to a temporary location first to avoid issues
// with the OS killing the current executable when its overwritten.
if rokit_link_existed {
if cfg!(target_os = "linux") && rokit_link_existed {
// On Linux, it's safe to remove the running binary.
// Moving to a temporary file can cause an error on some Linux systems
// due to /tmp being located on a different partition.
trace!(?rokit_path, "removing existing Rokit binary");
remove_file(&rokit_path).await?;
} else if rokit_link_existed {
// NOTE: If the currently running Rokit binary is being updated,
// we need to move it to a temporary location first to avoid issues
// with the OS killing the current executable when its overwritten.
let temp_file = tempfile::tempfile()?;
#[allow(unused_mut)]
let mut temp_path = temp_file.path()?;
Expand Down

0 comments on commit 5ef1fc4

Please sign in to comment.