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

Method update_policy_status

crates/openshell-server/src/persistence/sqlite.rs:587–622  ·  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

585 }
586
587 pub async fn update_policy_status(
588 &self,
589 sandbox_id: &str,
590 version: i64,
591 status: &str,
592 load_error: Option<&str>,
593 loaded_at_ms: Option<i64>,
594 ) -> PersistenceResult<bool> {
595 let Some(mut record) = self.get_policy_by_version(sandbox_id, version).await? else {
596 return Ok(false);
597 };
598
599 record.status = status.to_string();
600 record.load_error = load_error.map(ToOwned::to_owned);
601 record.loaded_at_ms = loaded_at_ms;
602 let payload = policy_payload_from_record(&record)?;
603 let now_ms = current_time_ms();
604
605 let result = sqlx::query(
606 r#"
607UPDATE "objects"
608SET "status" = ?4, "payload" = ?5, "updated_at_ms" = ?6
609WHERE "object_type" = ?1 AND "scope" = ?2 AND "version" = ?3
610"#,
611 )
612 .bind(POLICY_OBJECT_TYPE)
613 .bind(sandbox_id)
614 .bind(version)
615 .bind(status)
616 .bind(payload)
617 .bind(now_ms)
618 .execute(&self.pool)
619 .await
620 .map_err(|e| map_db_error(&e))?;
621 Ok(result.rows_affected() > 0)
622 }
623
624 pub async fn supersede_older_policies(
625 &self,

Calls 4

map_db_errorFunction · 0.85
current_time_msFunction · 0.70
get_policy_by_versionMethod · 0.45

Tested by 3

policy_supersede_olderFunction · 0.36