Mountain/IPC/WindAirCommands/
DownloadFile.rs1#![allow(non_snake_case)]
2
3use crate::{
7 IPC::WindAirCommands::{DownloadResultDTO, GetAirAddress, GetOrCreateAirClient},
8 dev_log,
9};
10
11#[tauri::command]
12pub async fn DownloadFile(url:String, destination:String) -> Result<DownloadResultDTO::Struct, String> {
13 dev_log!("grpc", "[WindAirCommands] DownloadFile called: {} -> {}", url, destination);
14
15 let air_address = GetAirAddress::Fn()?;
16 let client = GetOrCreateAirClient::Fn(air_address).await?;
17
18 let request_id = uuid::Uuid::new_v4().to_string();
19
20 let file_info = client
21 .download_file(request_id, url, destination, String::new(), std::collections::HashMap::new())
22 .await
23 .map_err(|e| format!("File download failed: {:?}", e))?;
24
25 let result = DownloadResultDTO::Struct {
26 success:true,
27 file_path:file_info.file_path,
28 file_size:file_info.file_size,
29 checksum:file_info.checksum,
30 };
31
32 dev_log!("grpc", "[WindAirCommands] File download completed");
33 Ok(result)
34}