From 5a82f8616fa33514123f9c0df7ed95c3cd290f20 Mon Sep 17 00:00:00 2001 From: daimond113 <72147841+daimond113@users.noreply.github.com> Date: Sat, 16 Nov 2024 18:36:45 +0100 Subject: [PATCH] fix: fix self-install cross-device move --- CHANGELOG.md | 4 ++++ src/cli/version.rs | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6995b23..3a066bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] +### Fixed +- Fix `self-install` doing a cross-device move by @daimond113 + ## [0.5.0-rc.9] - 2024-11-16 ### Fixed - Correctly link Wally server packages by @daimond113 diff --git a/src/cli/version.rs b/src/cli/version.rs index 9224ecd..38e9ec9 100644 --- a/src/cli/version.rs +++ b/src/cli/version.rs @@ -287,11 +287,13 @@ pub async fn update_bin_exe(downloaded_file: &Path) -> anyhow::Result<()> { )); let mut downloaded_file = downloaded_file.to_path_buf(); - if cfg!(target_os = "linux") && bin_exe_path.exists() { + let exists = bin_exe_path.exists(); + + if cfg!(target_os = "linux") && exists { fs::remove_file(&bin_exe_path) .await .context("failed to remove existing executable")?; - } else { + } else if exists { let tempfile = tempfile::Builder::new() .make(|_| Ok(())) .context("failed to create temporary file")?;