Handle update operation
(os: &Os, session: &ChatSession, path: &str)
| 342 | |
| 343 | /// Handle update operation |
| 344 | async fn handle_update(os: &Os, session: &ChatSession, path: &str) -> OperationResult { |
| 345 | match Self::validate_and_sanitize_path(os, path) { |
| 346 | Ok(sanitized_path) => { |
| 347 | let agent = Self::get_agent(session); |
| 348 | let async_knowledge_store = match KnowledgeStore::get_async_instance(os, agent).await { |
| 349 | Ok(store) => store, |
| 350 | Err(e) => { |
| 351 | return OperationResult::Error(format!("Error accessing knowledge base directory: {}", e)); |
| 352 | }, |
| 353 | }; |
| 354 | let mut store = async_knowledge_store.lock().await; |
| 355 | |
| 356 | match store.update_by_path(&sanitized_path).await { |
| 357 | Ok(message) => OperationResult::Info(message), |
| 358 | Err(e) => OperationResult::Error(format!("Failed to update: {}", e)), |
| 359 | } |
| 360 | }, |
| 361 | Err(e) => OperationResult::Error(e), |
| 362 | } |
| 363 | } |
| 364 | |
| 365 | /// Handle clear operation |
| 366 | async fn handle_clear(os: &Os, session: &mut ChatSession) -> OperationResult { |
nothing calls this directly
no test coverage detected