Skip to content

Commit

Permalink
fix(updater): add status code judge
Browse files Browse the repository at this point in the history
  • Loading branch information
greenhat616 committed Dec 29, 2023
1 parent 6c992b7 commit 67e26bc
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions backend/tauri/src/core/updater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,11 @@ impl Updater {
"failed to copy core: {}, trying to use elevated permission to copy and override core",
err
);
#[cfg(target_os = "windows")]
{
// 防止 UAC 弹窗堵塞主线程
tokio::task::spawn_blocking(move || {

// 防止 UAC 弹窗堵塞主线程
let status_code = tokio::task::spawn_blocking(move || {
#[cfg(target_os = "windows")]
{
RunasCommand::new("cmd")
.args(&[
"/C",
Expand All @@ -187,18 +188,21 @@ impl Updater {
target_core.to_str().unwrap(),
])
.status()
})
.await??;
}
#[cfg(not(target_os = "windows"))]
{
RunasCommand::new("cp")
.args(&[
"-f",
tmp_core_path.to_str().unwrap(),
target_core.to_str().unwrap(),
])
.status()?;
}
#[cfg(not(target_os = "windows"))]
{
RunasCommand::new("cp")
.args(&[
"-f",
tmp_core_path.to_str().unwrap(),
target_core.to_str().unwrap(),
])
.status()?;
}
})
.await??;
if !status_code.success() {
anyhow::bail!("failed to copy core: {}", status_code);
}
}
};
Expand Down

0 comments on commit 67e26bc

Please sign in to comment.