Skip to content

Commit 80e0fad

Browse files
committed
fix (core): 修复 windows 编译导致权限问题
1 parent 21d756f commit 80e0fad

2 files changed

Lines changed: 15 additions & 8 deletions

File tree

src-tauri/src/update/update_linux.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,14 @@ fn replace_executable(
6767
std::fs::copy(update_path, current_exe)?;
6868

6969
// 设置可执行权限
70-
use std::os::unix::fs::PermissionsExt;
71-
let mut perms = std::fs::metadata(current_exe)?.permissions();
72-
perms.set_mode(0o755);
73-
std::fs::set_permissions(current_exe, perms)?;
70+
#[cfg(unix)]
71+
{
72+
use std::os::unix::fs::PermissionsExt;
73+
let mut perms = std::fs::metadata(current_exe)?.permissions();
74+
perms.set_mode(0o755);
75+
std::fs::set_permissions(current_exe, perms)?;
76+
}
77+
7478
info!("安装更新 -> 可执行文件权限设置完成");
7579

7680
Ok(())

src-tauri/src/update/update_mac.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,10 +252,13 @@ rm "$0"
252252
std::fs::write(&script_path, script_content)?;
253253

254254
// 设置脚本可执行权限
255-
use std::os::unix::fs::PermissionsExt;
256-
let mut perms = std::fs::metadata(&script_path)?.permissions();
257-
perms.set_mode(0o755);
258-
std::fs::set_permissions(&script_path, perms)?;
255+
#[cfg(unix)]
256+
{
257+
use std::os::unix::fs::PermissionsExt;
258+
let mut perms = std::fs::metadata(&script_path)?.permissions();
259+
perms.set_mode(0o755);
260+
std::fs::set_permissions(&script_path, perms)?;
261+
}
259262

260263
info!("安装更新 -> 启动更新脚本: {}", script_path.display());
261264

0 commit comments

Comments
 (0)