MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / cbm_replace_binary

Function cbm_replace_binary

src/cli/cli.c:1201–1219  ·  view source on GitHub ↗

Replace a binary transactionally, retaining the old target until the exact * staged bytes have been published and validated. */

Source from the content-addressed store, hash-verified

1199/* Replace a binary transactionally, retaining the old target until the exact
1200 * staged bytes have been published and validated. */
1201int cbm_replace_binary(const char *path, const unsigned char *data, int len, int mode) {
1202 if (!path || !data || len <= 0) {
1203 return CLI_ERR;
1204 }
1205 cbm_activation_transaction_t *transaction = NULL;
1206 cbm_activation_transaction_status_t status =
1207 cbm_activation_transaction_stage_bytes(path, data, (size_t)len, &transaction);
1208 cli_binary_validator_t validator;
1209 if (status != CBM_ACTIVATION_TRANSACTION_OK || !transaction ||
1210 !cli_activation_transaction_expected_build(transaction, &validator)) {
1211 (void)cli_activation_transaction_abort(&transaction);
1212 return CLI_ERR;
1213 }
1214 if (cli_activation_transaction_commit_validated(transaction, &validator, mode) != CLI_OK) {
1215 (void)cli_activation_transaction_abort(&transaction);
1216 return CLI_ERR;
1217 }
1218 return cli_activation_transaction_finalize_close(&transaction);
1219}
1220
1221/* ── Skill file content (embedded) ────────────────────────────── */
1222

Callers 1

test_cli.cFile · 0.85

Tested by

no test coverage detected