Skip to content

Commit

Permalink
fix: update bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Horbin-Magician committed Sep 23, 2024
1 parent 367f580 commit 52702f3
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rotor"
version = "0.7.0"
version = "0.7.1"
authors = ["Horbin"]
edition = "2021"
license = "MIT"
Expand Down
22 changes: 12 additions & 10 deletions src/module/setting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,25 +192,27 @@ impl Setting {
});

let setting_win_clone = setting_win.as_weak();
let msg_sender = msg_sender.clone();
setting_win.on_update(move || {
if let Some(setting_win) = setting_win_clone.upgrade() {
setting_win.set_block(true);
setting_win.set_update_state(0);
}

let msg_sender = msg_sender.clone();
let setting_win_clone = setting_win_clone.clone();
std::thread::spawn(move || {
if let Ok(updater) = net_util::Updater::global().lock() {
updater.update_software()
.unwrap_or_else(
|e| {
log_util::log_error(format!("Failed to update software: {:?}", e));
setting_win_clone.upgrade_in_event_loop(move |setting_window| {
setting_window.set_block(false);
setting_window.set_update_state(2);
}).unwrap_or_else(|e| log_util::log_error(format!("Set setting_window back from updating: {:?}", e)));
}
);
match updater.update_software() {
Ok(_) => { let _ = msg_sender.send(AppMessage::Quit); },
Err(e) => {
log_util::log_error(format!("Failed to update software: {:?}", e));
setting_win_clone.upgrade_in_event_loop(move |setting_window| {
setting_window.set_block(false);
setting_window.set_update_state(2);
}).unwrap_or_else(|e| log_util::log_error(format!("Set setting_window back from updating: {:?}", e)));
}
}
}
});
});
Expand Down
8 changes: 5 additions & 3 deletions src/util/net_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,11 @@ impl Updater {
let file_response = reqwest::blocking::Client::new()
.get(format!("https://mirror.ghproxy.com/{}", download_url)).send()
.or_else( |_| {
reqwest::blocking::Client::new().get(download_url).send()
}
)?;
reqwest::blocking::Client::new().get(format!("https://ghp.ci/{}", download_url)).send()
})
.or_else( |_| {
reqwest::blocking::Client::new().get(download_url).send()
})?;

if file_response.status().is_success() {
let exe_path = env::current_exe()?;
Expand Down

0 comments on commit 52702f3

Please sign in to comment.