chore: try to auto update in case of startup crash (#758)
This commit is contained in:
parent
b00dff4256
commit
f2ecde8927
4 changed files with 17 additions and 8 deletions
|
|
@ -335,7 +335,7 @@ pub async fn start_launcher(
|
|||
}
|
||||
|
||||
crate::hooks::invalidate_profile_queries().await;
|
||||
crate::updater::spawn_update_check(auto_update);
|
||||
crate::updater::spawn_update_check(auto_update, state.services.events.clone());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,12 +36,16 @@ impl App for OneClientApp {
|
|||
);
|
||||
|
||||
let startup = actions.clone();
|
||||
let rescue_bus = events_bus.clone();
|
||||
spawn_forever(async move {
|
||||
match events::start_launcher(station, events_bus).await {
|
||||
// Must follow startup `sync_bundles` needs the launcher handle and firing
|
||||
// it early leaves `syncing_bundles` stuck disabling every launch button
|
||||
Ok(()) => startup.sync_bundles(),
|
||||
Err(err) => events::report_startup_failure(&station, &err),
|
||||
Err(err) => {
|
||||
events::report_startup_failure(&station, &err);
|
||||
oneclient_app::updater::spawn_update_check(false, rescue_bus);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -26,9 +26,9 @@ fn update_prompt(version: &str) -> Prompt<UpdateAnswer> {
|
|||
|
||||
const PROGRESS_STEP: u64 = 256 * 1024;
|
||||
|
||||
pub fn spawn_update_check(auto_install: bool) {
|
||||
pub fn spawn_update_check(auto_install: bool, events: EventBus) {
|
||||
tokio::spawn(async move {
|
||||
if let Err(err) = run_check(auto_install).await {
|
||||
if let Err(err) = run_check(auto_install, events).await {
|
||||
tracing::warn!("update check failed: {err:#}");
|
||||
}
|
||||
});
|
||||
|
|
@ -74,9 +74,7 @@ async fn run_simulated_update() -> anyhow::Result<()> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
async fn run_check(auto_install: bool) -> anyhow::Result<()> {
|
||||
let events = crate::launcher::state()?.services.events.clone();
|
||||
|
||||
async fn run_check(auto_install: bool, events: EventBus) -> anyhow::Result<()> {
|
||||
// `check_update` performs a blocking HTTP request so offload it to a thread pool
|
||||
let Some(update) = tokio::task::spawn_blocking(check_for_update).await?? else {
|
||||
tracing::info!("no update available");
|
||||
|
|
|
|||
|
|
@ -472,7 +472,14 @@ impl Component for LauncherUpdateSimulator {
|
|||
.secondary()
|
||||
.child(Icon::new(IconType::RefreshCw01).size(16.))
|
||||
.text("Check for Updates Now")
|
||||
.on_press(|_| crate::updater::spawn_update_check(false)),
|
||||
.on_press(|_| {
|
||||
if let Ok(state) = crate::launcher::state() {
|
||||
crate::updater::spawn_update_check(
|
||||
false,
|
||||
state.services.events.clone(),
|
||||
);
|
||||
}
|
||||
}),
|
||||
),
|
||||
)
|
||||
.into_element()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue