| 2 | use tauri_plugin_updater::UpdaterExt; |
| 3 | |
| 4 | pub async fn update(app: tauri::AppHandle) -> tauri_plugin_updater::Result<()> { |
| 5 | if let Some(update) = app.updater()?.check().await? { |
| 6 | let mut downloaded = 0; |
| 7 | |
| 8 | info!("updating"); |
| 9 | |
| 10 | // alternatively we could also call update.download() and update.install() separately |
| 11 | update |
| 12 | .download_and_install( |
| 13 | |chunk_length, content_length| { |
| 14 | downloaded += chunk_length; |
| 15 | debug!("downloaded {downloaded} from {content_length:?}"); |
| 16 | }, |
| 17 | || { |
| 18 | info!("download finished"); |
| 19 | }, |
| 20 | ) |
| 21 | .await?; |
| 22 | |
| 23 | info!("update installed"); |
| 24 | app.restart(); |
| 25 | } |
| 26 | |
| 27 | Ok(()) |
| 28 | } |