chore: update agent updater config

This commit is contained in:
Andrew Bastin
2024-10-03 22:20:45 +05:30
parent cd25ba7d92
commit 025a8fc0cb
2 changed files with 23 additions and 27 deletions

View File

@@ -11,7 +11,7 @@ pub mod util;
use state::AppState; use state::AppState;
use std::sync::Arc; use std::sync::Arc;
use tauri::{Listener, Manager, Url, WebviewWindowBuilder}; use tauri::{Listener, Manager, WebviewWindowBuilder};
use tauri_plugin_updater::UpdaterExt; use tauri_plugin_updater::UpdaterExt;
use tokio_util::sync::CancellationToken; use tokio_util::sync::CancellationToken;
@@ -54,35 +54,23 @@ pub fn run() {
#[cfg(desktop)] #[cfg(desktop)]
{ {
// We use env variables to define the pubkey for installer to check let _ = app.handle()
let updater_pub_key = option_env!("UPDATER_PUB_KEY"); .plugin(tauri_plugin_updater::Builder::new() .build());
let updater_url = option_env!("UPDATER_URL");
if let (Some(pub_key), Some(updater_url)) = (updater_pub_key, updater_url) { let _ = app.handle()
let _ = app.handle() .plugin(tauri_plugin_dialog::init());
.plugin(tauri_plugin_updater::Builder::new() .build());
let _ = app.handle() let updater = app.updater_builder()
.plugin(tauri_plugin_dialog::init()); .build()
.unwrap();
let updater_url: Url = updater_url.parse().unwrap(); let app_handle_ref = app_handle.clone();
let updater = app.updater_builder() tauri::async_runtime::spawn_blocking(|| {
.pubkey(pub_key) tauri::async_runtime::block_on(async {
.endpoints( updater::check_and_install_updates(app_handle_ref, updater).await;
vec![updater_url] })
) });
.build()
.unwrap();
let app_handle_ref = app_handle.clone();
tauri::async_runtime::spawn_blocking(|| {
tauri::async_runtime::block_on(async {
updater::check_and_install_updates(app_handle_ref, updater).await;
})
});
}
}; };
let app_state = Arc::new(AppState::new(app_handle.clone())); let app_state = Arc::new(AppState::new(app_handle.clone()));

View File

@@ -28,7 +28,7 @@
"csp": null "csp": null
} }
}, },
"bundle": { "bundle": {
"active": true, "active": true,
"targets": "all", "targets": "all",
"icon": [ "icon": [
@@ -39,5 +39,13 @@
"icons/icon.ico" "icons/icon.ico"
], ],
"createUpdaterArtifacts": true "createUpdaterArtifacts": true
},
"plugins" : {
"updater": {
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDI1MjZGQTNFRjA1NEFFMDEKUldRQnJsVHdQdm9tSlNMLzNxKzJOM24wdC9SYUZHckFpeUZoWW1xb1dtdVpSa2dWMkRGdkV2WmsK",
"endpoints": [
"https://releases.hoppscotch.com/hoppscotch-agent.json"
]
}
} }
} }