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

Method validated_primary

atomic-repository/src/tracking/tree_ops.rs:262–284  ·  view source on GitHub ↗
(
        txn: &T,
        path: &str,
    )

Source from the content-addressed store, hash-verified

260 }
261
262 fn validated_primary<T: TreeTxnT>(
263 txn: &T,
264 path: &str,
265 ) -> Result<Option<Inode>, TreeProjectionError> {
266 let Some(primary) = txn
267 .get_inode(path)
268 .map_err(|error| TreeProjectionError::Database(error.to_string()))?
269 else {
270 return Ok(None);
271 };
272 let reverse = txn
273 .get_path(primary)
274 .map_err(|error| TreeProjectionError::Database(error.to_string()))?;
275 if reverse.as_deref() != Some(path) {
276 return Err(TreeProjectionError::IncompleteMetadata(format!(
277 "TREE maps '{}' to inode {}, but its REV_TREE row is {:?}",
278 path,
279 primary.get(),
280 reverse
281 )));
282 }
283 Ok(Some(primary))
284 }
285
286 fn validate<T: TreeTxnT + PathClaimTxnT>(&self, txn: &T) -> Result<(), TreeProjectionError> {
287 txn.validate_tree_bijection()

Callers

nothing calls this directly

Calls 2

get_inodeMethod · 0.45
get_pathMethod · 0.45

Tested by

no test coverage detected