(
app_state: &AppState,
raw_path: &str,
)
| 297 | } |
| 298 | |
| 299 | pub async fn get_path_metadata( |
| 300 | app_state: &AppState, |
| 301 | raw_path: &str, |
| 302 | ) -> Result<serde_json::Value, String> { |
| 303 | match resolve_desktop_path_target(app_state, raw_path, None).await? { |
| 304 | DesktopPathTarget::Local { |
| 305 | requested_path, |
| 306 | resolved_path, |
| 307 | is_runtime_artifact, |
| 308 | } => { |
| 309 | let metadata = |
| 310 | stat_local_path_metadata(&requested_path, &resolved_path, is_runtime_artifact)?; |
| 311 | serde_json::to_value(metadata) |
| 312 | .map_err(|e| format!("Failed to serialize file metadata: {}", e)) |
| 313 | } |
| 314 | DesktopPathTarget::Remote { |
| 315 | requested_path, |
| 316 | entry, |
| 317 | } => { |
| 318 | let remote_fs = app_state |
| 319 | .get_remote_file_service_async() |
| 320 | .await |
| 321 | .map_err(|e| format!("Remote file service not available: {}", e))?; |
| 322 | |
| 323 | let stat_entry = remote_fs |
| 324 | .stat(&entry.connection_id, &requested_path) |
| 325 | .await |
| 326 | .map_err(|e| format!("Failed to stat remote file: {}", e))?; |
| 327 | |
| 328 | let (is_file, is_dir, size, modified) = match stat_entry { |
| 329 | Some(entry) => ( |
| 330 | entry.is_file, |
| 331 | entry.is_dir, |
| 332 | entry.size.unwrap_or(0), |
| 333 | entry.modified.unwrap_or(0), |
| 334 | ), |
| 335 | None => (false, false, 0, 0), |
| 336 | }; |
| 337 | |
| 338 | serde_json::to_value(RemoteFileMetadata { |
| 339 | path: requested_path, |
| 340 | modified, |
| 341 | size, |
| 342 | is_file, |
| 343 | is_dir, |
| 344 | is_remote: true, |
| 345 | }) |
| 346 | .map_err(|e| format!("Failed to serialize remote file metadata: {}", e)) |
| 347 | } |
| 348 | } |
| 349 | } |
| 350 | |
| 351 | pub async fn rename_path( |
| 352 | app_state: &AppState, |
no test coverage detected