Tauri Updater attempt hopefully works first try
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
use crate::{
|
||||
init::{lifecycle::validate_server_health, tracing::init_logging},
|
||||
services::{
|
||||
app_update::update_app,
|
||||
auth::get_session_token,
|
||||
cursor::init_cursor_tracking,
|
||||
presence_modules::init_modules,
|
||||
@@ -20,6 +21,7 @@ pub mod tracing;
|
||||
pub async fn launch_app() {
|
||||
init_logging();
|
||||
open_splash_window();
|
||||
update_app().await;
|
||||
init_app_state();
|
||||
init_system_tray();
|
||||
init_cursor_tracking().await;
|
||||
|
||||
@@ -133,6 +133,7 @@ pub fn run() {
|
||||
.expect("Failed to export TypeScript bindings");
|
||||
|
||||
tauri::Builder::default()
|
||||
.plugin(tauri_plugin_updater::Builder::new().build())
|
||||
.plugin(tauri_plugin_opener::init())
|
||||
.plugin(tauri_plugin_positioner::init())
|
||||
.plugin(tauri_plugin_dialog::init())
|
||||
|
||||
48
src-tauri/src/services/app_update.rs
Normal file
48
src-tauri/src/services/app_update.rs
Normal file
@@ -0,0 +1,48 @@
|
||||
use tauri_plugin_updater::UpdaterExt;
|
||||
use tracing::{error, info};
|
||||
|
||||
use crate::get_app_handle;
|
||||
|
||||
pub async fn update_app() {
|
||||
let app = get_app_handle();
|
||||
if let Some(update) = match match app.updater() {
|
||||
Ok(it) => it,
|
||||
Err(err) => {
|
||||
error!("failed to get updater: {err:?}");
|
||||
return;
|
||||
}
|
||||
}
|
||||
.check()
|
||||
.await
|
||||
{
|
||||
Ok(it) => it,
|
||||
Err(err) => {
|
||||
error!("failed to check for update: {err:?}");
|
||||
return;
|
||||
}
|
||||
} {
|
||||
let mut downloaded = 0;
|
||||
|
||||
match update
|
||||
.download_and_install(
|
||||
|chunk_length, content_length| {
|
||||
downloaded += chunk_length;
|
||||
println!("downloaded {downloaded} from {content_length:?}");
|
||||
},
|
||||
|| {
|
||||
info!("download finished");
|
||||
},
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(it) => it,
|
||||
Err(err) => {
|
||||
error!("failed to install update: {err:?}");
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
info!("update installed");
|
||||
app.restart();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
pub mod app_data;
|
||||
pub mod app_events;
|
||||
pub mod app_menu;
|
||||
pub mod app_update;
|
||||
pub mod auth;
|
||||
pub mod client_config;
|
||||
pub mod cursor;
|
||||
|
||||
Reference in New Issue
Block a user