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

Fix cross-device link error when running self-update on Linux #63

Merged
merged 2 commits into from
Aug 9, 2024
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
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