feat(updater): wire tauri-plugin-updater with GitHub releases endpoint + update toast
This commit is contained in:
@@ -7,4 +7,5 @@ pub mod live;
|
||||
pub mod models;
|
||||
pub mod transcription;
|
||||
pub mod transcripts;
|
||||
pub mod update;
|
||||
pub mod windows;
|
||||
|
||||
38
src-tauri/src/commands/update.rs
Normal file
38
src-tauri/src/commands/update.rs
Normal file
@@ -0,0 +1,38 @@
|
||||
use tauri::AppHandle;
|
||||
use tauri_plugin_updater::UpdaterExt;
|
||||
|
||||
/// Check for an available update. Returns Some(version_string) if one is
|
||||
/// available, None if already up to date, and Err if the check fails.
|
||||
#[tauri::command]
|
||||
pub async fn check_for_update(app: AppHandle) -> Result<Option<String>, String> {
|
||||
let update = app
|
||||
.updater()
|
||||
.map_err(|e| format!("Updater not available: {e}"))?
|
||||
.check()
|
||||
.await
|
||||
.map_err(|e| format!("Update check failed: {e}"))?;
|
||||
|
||||
match update {
|
||||
Some(u) => Ok(Some(u.version.to_string())),
|
||||
None => Ok(None),
|
||||
}
|
||||
}
|
||||
|
||||
/// Download and stage the update. The app will install it on next launch.
|
||||
#[tauri::command]
|
||||
pub async fn install_update(app: AppHandle) -> Result<(), String> {
|
||||
let update = app
|
||||
.updater()
|
||||
.map_err(|e| format!("Updater not available: {e}"))?
|
||||
.check()
|
||||
.await
|
||||
.map_err(|e| format!("Update check failed: {e}"))?
|
||||
.ok_or_else(|| "No update available".to_string())?;
|
||||
|
||||
update
|
||||
.download_and_install(|_, _| {}, || {})
|
||||
.await
|
||||
.map_err(|e| format!("Install failed: {e}"))?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user