230230//!
231231//! **Pending** is emitted when the download is started and **Done** when the install is complete. You can then ask to restart the application.
232232//!
233+ //! **Downloaded** is emitted when the download has finished.
234+ //!
233235//! **UpToDate** is emitted when the app already has the latest version installed and an update is not needed.
234236//!
235237//! **Error** is emitted when there is an error with the updater. We suggest to listen to this event even if the dialog is enabled.
249251//! tauri::UpdaterEvent::Pending => {
250252//! println!("update is pending!");
251253//! }
254+ //! tauri::UpdaterEvent::Downloaded => {
255+ //! println!("update has been downloaded!");
256+ //! }
252257//! tauri::UpdaterEvent::Updated => {
253258//! println!("app has been updated");
254259//! }
@@ -465,6 +470,8 @@ pub const EVENT_STATUS_PENDING: &str = "PENDING";
465470/// When you got this status, something went wrong
466471/// you can find the error message inside the `error` field.
467472pub const EVENT_STATUS_ERROR : & str = "ERROR" ;
473+ /// The update has been downloaded.
474+ pub const EVENT_STATUS_DOWNLOADED : & str = "DOWNLOADED" ;
468475/// When you receive this status, you should ask the user to restart
469476pub const EVENT_STATUS_SUCCESS : & str = "DONE" ;
470477/// When you receive this status, this is because the application is running last version
@@ -712,6 +719,7 @@ pub(crate) async fn download_and_install<R: Runtime>(update: core::Update<R>) ->
712719 send_status_update ( & update. app , UpdaterEvent :: Pending ) ;
713720
714721 let handle = update. app . clone ( ) ;
722+ let handle_ = handle. clone ( ) ;
715723
716724 // Launch updater download process
717725 // macOS we display the `Ready to restart dialog` asking to restart
@@ -723,6 +731,9 @@ pub(crate) async fn download_and_install<R: Runtime>(update: core::Update<R>) ->
723731 move |chunk_length, content_length| {
724732 send_download_progress_event ( & handle, chunk_length, content_length) ;
725733 } ,
734+ move || {
735+ send_status_update ( & handle_, UpdaterEvent :: Downloaded ) ;
736+ } ,
726737 )
727738 . await ;
728739
@@ -840,7 +851,7 @@ Release Notes:
840851 // Windows is closing the current App and launch the downloaded MSI when ready (the process stop here)
841852 // 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)
842853 update
843- . download_and_install ( pubkey. clone ( ) , |_, _| ( ) )
854+ . download_and_install ( pubkey. clone ( ) , |_, _| ( ) , || ( ) )
844855 . await ?;
845856
846857 // Ask user if we need to restart the application
0 commit comments