| 4315 | } |
| 4316 | |
| 4317 | async fn get_paths(Query(params): Query<PathQuery>) -> Result<Json<PathsResponse>> { |
| 4318 | let home = dirs::home_dir() |
| 4319 | .map(|p| p.to_string_lossy().to_string()) |
| 4320 | .unwrap_or_default(); |
| 4321 | let config = dirs::config_dir() |
| 4322 | .map(|p| p.to_string_lossy().to_string()) |
| 4323 | .unwrap_or_default(); |
| 4324 | let state = dirs::data_dir() |
| 4325 | .map(|p| p.to_string_lossy().to_string()) |
| 4326 | .unwrap_or_default(); |
| 4327 | let cwd = std::env::current_dir() |
| 4328 | .map(|p| p.to_string_lossy().to_string()) |
| 4329 | .unwrap_or_default(); |
| 4330 | let worktree = params.directory.as_deref().unwrap_or(&cwd).to_string(); |
| 4331 | let directory = worktree.clone(); |
| 4332 | Ok(Json(PathsResponse { |
| 4333 | home, |
| 4334 | state, |
| 4335 | config, |
| 4336 | worktree, |
| 4337 | directory, |
| 4338 | })) |
| 4339 | } |
| 4340 | |
| 4341 | #[derive(Debug, Deserialize)] |
| 4342 | struct PathQuery { |