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

Method update_policy_status

crates/openshell-server/src/persistence/postgres.rs:566–601  ·  view source on GitHub ↗
(
        &self,
        sandbox_id: &str,
        version: i64,
        status: &str,
        load_error: Option<&str>,
        loaded_at_ms: Option<i64>,
    )

Source from the content-addressed store, hash-verified

564 }
565
566 pub async fn update_policy_status(
567 &self,
568 sandbox_id: &str,
569 version: i64,
570 status: &str,
571 load_error: Option<&str>,
572 loaded_at_ms: Option<i64>,
573 ) -> PersistenceResult<bool> {
574 let Some(mut record) = self.get_policy_by_version(sandbox_id, version).await? else {
575 return Ok(false);
576 };
577
578 record.status = status.to_string();
579 record.load_error = load_error.map(ToOwned::to_owned);
580 record.loaded_at_ms = loaded_at_ms;
581 let payload = policy_payload_from_record(&record)?;
582 let now_ms = current_time_ms();
583
584 let result = sqlx::query(
585 r"
586UPDATE objects
587SET status = $4, payload = $5, updated_at_ms = $6
588WHERE object_type = $1 AND scope = $2 AND version = $3
589",
590 )
591 .bind(POLICY_OBJECT_TYPE)
592 .bind(sandbox_id)
593 .bind(version)
594 .bind(status)
595 .bind(payload)
596 .bind(now_ms)
597 .execute(&self.pool)
598 .await
599 .map_err(|e| map_db_error(&e))?;
600 Ok(result.rows_affected() > 0)
601 }
602
603 pub async fn supersede_older_policies(
604 &self,

Callers

nothing calls this directly

Calls 4

map_db_errorFunction · 0.85
current_time_msFunction · 0.70
get_policy_by_versionMethod · 0.45

Tested by

no test coverage detected