From 007049f1411f5033fcafaf75250692660bb2721d Mon Sep 17 00:00:00 2001 From: Nicolas Chan Date: Mon, 9 Sep 2024 20:06:25 -0700 Subject: [PATCH] Maybe fix windows build --- insanity-native-tui-app/src/update.rs | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/insanity-native-tui-app/src/update.rs b/insanity-native-tui-app/src/update.rs index 2c8fa54..999b56d 100644 --- a/insanity-native-tui-app/src/update.rs +++ b/insanity-native-tui-app/src/update.rs @@ -1,5 +1,3 @@ -use std::os::unix::fs::PermissionsExt; - use insanity_core::built_info; use log::{info, warn}; use tokio::{fs::create_dir_all, io::AsyncWriteExt}; @@ -157,11 +155,27 @@ pub async fn update(dry_run: bool, force: bool) -> anyhow::Result<()> { current_exe.display(), new_exe_path.display(), ); - tokio::fs::rename(&new_exe_path, ¤t_exe).await?; + match tokio::fs::rename(&new_exe_path, ¤t_exe).await { + Ok(_) => info!( + "Replaced {} with {}", + current_exe.display(), + new_exe_path.display() + ), + Err(e) => { + warn!( + "Failed to replace {} with {}: {}", + current_exe.display(), + new_exe_path.display(), + e + ); + return Err(e.into()); + } + } } #[cfg(unix)] { + use std::os::unix::fs::PermissionsExt; let current_exe_file = tokio::fs::File::open(¤t_exe).await?; let mut perms = current_exe_file.metadata().await?.permissions(); perms.set_mode(perms.mode() | 0o111); // Add execute permission