MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / update_trunk_path

Function update_trunk_path

atomic-core/src/apply/file_ops.rs:885–909  ·  view source on GitHub ↗

Update a trunk's path.

(
    txn: &mut T,
    trunk_id: TrunkId,
    new_path: &str,
)

Source from the content-addressed store, hash-verified

883
884/// Update a trunk's path.
885fn update_trunk_path<T: MutTxnT>(
886 txn: &mut T,
887 trunk_id: TrunkId,
888 new_path: &str,
889) -> PristineResult<()> {
890 let key = encode_trunk_id(&trunk_id);
891
892 // Get existing trunk
893 if let Some(mut serialized) = txn.get_crdt_trunk(&key)? {
894 // Remove old path index
895 txn.del_crdt_path_trunk(&serialized.path)?;
896
897 // Update path
898 serialized.path = new_path.to_string();
899
900 // Re-encode and store
901 let value = encode_trunk_value(&serialized);
902 txn.put_crdt_trunk(&key, &value)?;
903
904 // Add new path index
905 txn.put_crdt_path_trunk(new_path, &key)?;
906 }
907
908 Ok(())
909}
910
911/// Store a branch in the CRDT tables.
912fn put_branch<T: MutTxnT>(

Callers 1

apply_trunk_opFunction · 0.85

Calls 6

encode_trunk_idFunction · 0.85
encode_trunk_valueFunction · 0.85
del_crdt_path_trunkMethod · 0.80
put_crdt_trunkMethod · 0.80
put_crdt_path_trunkMethod · 0.80
get_crdt_trunkMethod · 0.45

Tested by

no test coverage detected