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

Function tracked_under_prefix

atomic-repository/src/tracking/tree_ops.rs:430–453  ·  view source on GitHub ↗

Get all tracked paths under a directory prefix. # Arguments `txn` - A transaction (read or write) `prefix` - The directory prefix to search under

(
    txn: &T,
    prefix: &str,
)

Source from the content-addressed store, hash-verified

428/// * `txn` - A transaction (read or write)
429/// * `prefix` - The directory prefix to search under
430pub fn tracked_under_prefix<T: TreeTxnT>(
431 txn: &T,
432 prefix: &str,
433) -> TrackingResult<Vec<(String, Inode)>> {
434 let iter = txn
435 .iter_tree()
436 .map_err(|e| TrackingError::Database(e.to_string()))?;
437
438 let prefix_normalized = if prefix.ends_with('/') {
439 prefix.to_string()
440 } else {
441 format!("{}/", prefix)
442 };
443
444 let mut results = Vec::new();
445 for result in iter {
446 let (path, inode) = result.map_err(|e| TrackingError::Database(e.to_string()))?;
447 if path.starts_with(&prefix_normalized) || path == prefix.trim_end_matches('/') {
448 results.push((path, inode));
449 }
450 }
451
452 Ok(results)
453}

Callers 4

removeMethod · 0.85
tracked_files_underMethod · 0.85

Calls 2

iter_treeMethod · 0.45
pushMethod · 0.45

Tested by 1