Skip to content

Commit 5d85d09

Browse files
authored
fix(core): Send updater status events when default dialog is enabled, closes #7128 (#7157)
1 parent 076e1a8 commit 5d85d09

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

.changes/updater-dialog-events.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
tauri: patch:enhance
3+
---
4+
5+
Send updater status events even if default dialog is enabled.

core/tauri/src/updater/mod.rs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -423,8 +423,10 @@ pub(crate) async fn check_update_with_dialog<R: Runtime>(handle: AppHandle<R>) {
423423
Ok(updater) => {
424424
let pubkey = updater_config.pubkey.clone();
425425

426-
// if dialog enabled only
427-
if updater.should_update && updater_config.dialog {
426+
if !updater.should_update {
427+
send_status_update(&handle, UpdaterEvent::AlreadyUpToDate);
428+
} else if updater_config.dialog {
429+
// if dialog enabled only
428430
let body = updater.body.clone().unwrap_or_else(|| String::from(""));
429431
let dialog =
430432
prompt_for_install(&updater.clone(), &package_info.name, &body.clone(), pubkey).await;
@@ -591,14 +593,28 @@ Release Notes:
591593
);
592594

593595
if should_install {
596+
let handle = update.app.clone();
597+
let handle_ = handle.clone();
598+
594599
// Launch updater download process
595600
// macOS we display the `Ready to restart dialog` asking to restart
596601
// Windows is closing the current App and launch the downloaded MSI when ready (the process stop here)
597602
// Linux we replace the AppImage by launching a new install, it start a new AppImage instance, so we're closing the previous. (the process stop here)
598603
update
599-
.download_and_install(pubkey.clone(), |_, _| (), || ())
604+
.download_and_install(
605+
pubkey.clone(),
606+
move |chunk_length, content_length| {
607+
send_download_progress_event(&handle, chunk_length, content_length);
608+
},
609+
move || {
610+
send_status_update(&handle_, UpdaterEvent::Downloaded);
611+
},
612+
)
600613
.await?;
601614

615+
// emit {"status": "DONE"}
616+
send_status_update(&update.app, UpdaterEvent::Updated);
617+
602618
// Ask user if we need to restart the application
603619
let should_exit = ask(
604620
parent_window,

0 commit comments

Comments
 (0)