MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / handle_clear_draft_chunks

Function handle_clear_draft_chunks

crates/openshell-server/src/grpc/policy.rs:2998–3032  ·  view source on GitHub ↗
(
    state: &Arc<ServerState>,
    request: Request<ClearDraftChunksRequest>,
)

Source from the content-addressed store, hash-verified

2996}
2997
2998pub(super) async fn handle_clear_draft_chunks(
2999 state: &Arc<ServerState>,
3000 request: Request<ClearDraftChunksRequest>,
3001) -> Result<Response<ClearDraftChunksResponse>, Status> {
3002 let req = request.into_inner();
3003 if req.name.is_empty() {
3004 return Err(Status::invalid_argument("name is required"));
3005 }
3006
3007 let sandbox = state
3008 .store
3009 .get_message_by_name::<Sandbox>(&req.name)
3010 .await
3011 .map_err(|e| Status::internal(format!("fetch sandbox failed: {e}")))?
3012 .ok_or_else(|| Status::not_found("sandbox not found"))?;
3013 let sandbox_id = sandbox.object_id().to_string();
3014
3015 let deleted = state
3016 .store
3017 .delete_draft_chunks(&sandbox_id, "pending")
3018 .await
3019 .map_err(|e| Status::internal(format!("delete draft chunks failed: {e}")))?;
3020
3021 state.sandbox_watch_bus.notify(&sandbox_id);
3022
3023 info!(
3024 sandbox_id = %sandbox_id,
3025 chunks_cleared = deleted,
3026 "ClearDraftChunks: pending chunks cleared"
3027 );
3028
3029 Ok(Response::new(ClearDraftChunksResponse {
3030 chunks_cleared: u32::try_from(deleted).unwrap_or(0),
3031 }))
3032}
3033
3034pub(super) async fn handle_get_draft_history(
3035 state: &Arc<ServerState>,

Callers 2

clear_draft_chunksMethod · 0.85

Calls 4

object_idMethod · 0.80
notifyMethod · 0.80
is_emptyMethod · 0.45
delete_draft_chunksMethod · 0.45

Tested by

no test coverage detected