Skip to content

Commit

Permalink
Maybe fix windows build
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolaschan committed Sep 10, 2024
1 parent 7b1ccd1 commit 007049f
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions insanity-native-tui-app/src/update.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -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, &current_exe).await?;
match tokio::fs::rename(&new_exe_path, &current_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(&current_exe).await?;
let mut perms = current_exe_file.metadata().await?.permissions();
perms.set_mode(perms.mode() | 0o111); // Add execute permission
Expand Down

0 comments on commit 007049f

Please sign in to comment.