AirLibrary/Client/AirClient/
GetFileInfo.rs1use tonic::Request;
7
8use crate::{
9 AirError,
10 Client::AirClient::{AirClient, ExtendedFileInfo},
11 Vine::Generated::air::FileInfoRequest,
12 dev_log,
13};
14
15impl AirClient {
16 pub async fn GetFileInfo(&self, request_id:String, path:String) -> Result<ExtendedFileInfo::Struct, AirError> {
18 let PathDisplay = path.clone();
19
20 dev_log!("grpc", "[AirClient] Getting file info for: {}", path);
21
22 let RequestPayload = FileInfoRequest { request_id, path };
23
24 let Client = self
25 .Client()
26 .ok_or_else(|| AirError::Network("Air client not initialized".to_string()))?;
27
28 let mut ClientGuard = Client.lock().await;
29
30 match ClientGuard.get_file_info(Request::new(RequestPayload)).await {
31 Ok(Response) => {
32 let Response = Response.into_inner();
33
34 dev_log!(
35 "grpc",
36 "[AirClient] File info retrieved for: {} (exists: {})",
37 PathDisplay,
38 Response.exists
39 );
40
41 Ok(ExtendedFileInfo::Struct {
42 exists:Response.exists,
43 size:Response.size,
44 mime_type:Response.mime_type,
45 checksum:Response.checksum,
46 modified_time:Response.modified_time,
47 })
48 },
49
50 Err(Status) => {
51 dev_log!("grpc", "error: [AirClient] Get file info RPC error: {}", Status);
52
53 Err(AirError::Network(format!("Get file info RPC error: {}", Status)))
54 },
55 }
56 }
57}