Skip to main content

Mountain/IPC/WindAirCommands/
ApplyUpdate.rs

1#![allow(non_snake_case)]
2
3//! `ApplyUpdate` Tauri command - tell Air to install a
4//! previously downloaded update package.
5
6use crate::{
7	IPC::WindAirCommands::{GetAirAddress, GetOrCreateAirClient},
8	dev_log,
9};
10
11#[tauri::command]
12pub async fn ApplyUpdate(update_id:String, update_path:String) -> Result<bool, String> {
13	dev_log!(
14		"grpc",
15		"[WindAirCommands] ApplyUpdate called: id={}, path={}",
16		update_id,
17		update_path
18	);
19
20	let air_address = GetAirAddress::Fn()?;
21	let client = GetOrCreateAirClient::Fn(air_address).await?;
22
23	let request_id = uuid::Uuid::new_v4().to_string();
24
25	client
26		.apply_update(request_id, update_id, update_path)
27		.await
28		.map_err(|e| format!("Update application failed: {:?}", e))?;
29
30	dev_log!("grpc", "[WindAirCommands] Update applied successfully");
31	Ok(true)
32}