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

Method update_draft_chunk_rule

crates/openshell-server/src/persistence/sqlite.rs:779–811  ·  view source on GitHub ↗
(
        &self,
        id: &str,
        proposed_rule: &[u8],
    )

Source from the content-addressed store, hash-verified

777 }
778
779 pub async fn update_draft_chunk_rule(
780 &self,
781 id: &str,
782 proposed_rule: &[u8],
783 ) -> PersistenceResult<bool> {
784 let Some(mut record) = self.get_draft_chunk(id).await? else {
785 return Ok(false);
786 };
787
788 if record.status != "pending" {
789 return Ok(false);
790 }
791
792 record.proposed_rule = proposed_rule.to_vec();
793 record.last_seen_ms = current_time_ms();
794 let payload = draft_chunk_payload_from_record(&record)?;
795
796 let result = sqlx::query(
797 r#"
798UPDATE "objects"
799SET "payload" = ?3, "updated_at_ms" = ?4
800WHERE "object_type" = ?1 AND "id" = ?2 AND "status" = 'pending'
801"#,
802 )
803 .bind(DRAFT_CHUNK_OBJECT_TYPE)
804 .bind(id)
805 .bind(payload)
806 .bind(record.last_seen_ms)
807 .execute(&self.pool)
808 .await
809 .map_err(|e| map_db_error(&e))?;
810 Ok(result.rows_affected() > 0)
811 }
812
813 pub async fn delete_draft_chunks(
814 &self,

Callers 1

handle_edit_draft_chunkFunction · 0.45

Calls 4

map_db_errorFunction · 0.85
current_time_msFunction · 0.70
get_draft_chunkMethod · 0.45

Tested by

no test coverage detected