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

Function collect_tracked_files

atomic-core/src/record/workflow/collect.rs:359–404  ·  view source on GitHub ↗

Collect tracked files from the pristine database. Iterates over the TREE table to find all files tracked by the repository. Results can be filtered by path prefix. # Arguments `txn` - Read transaction for pristine database `prefix` - Path prefix filter (empty = all files) # Returns A `CollectionResult ` containing all tracked files. # Errors Returns `RecordError::Pristine` if da

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

Source from the content-addressed store, hash-verified

357/// let result = collect_tracked_files(&txn, "src/")?;
358/// ```
359pub fn collect_tracked_files<T>(
360 txn: &T,
361 prefix: &str,
362) -> RecordResult<CollectionResult<TrackedFile>>
363where
364 T: GraphTxnT + TreeTxnT + ViewTxnT,
365{
366 let mut result = CollectionResult::new();
367
368 // Iterate over all tree entries (trait doesn't support prefix filtering)
369 let iter = txn
370 .iter_tree()
371 .map_err(|e| RecordError::Pristine(Box::new(e)))?;
372
373 for item in iter {
374 match item {
375 Ok((path, inode)) => {
376 // Filter by prefix if specified
377 if !prefix.is_empty() && !path.starts_with(prefix) {
378 result.add_skipped();
379 continue;
380 }
381
382 // Get the position for this inode
383 match txn.inode_position(inode) {
384 Ok(Some(position)) => {
385 let file = TrackedFile::new(&path, inode, position);
386 result.add(file);
387 }
388 Ok(None) => {
389 // Inode exists but has no position - might be a bug or deleted
390 result.add_error(&path, "Inode has no graph position");
391 }
392 Err(e) => {
393 result.add_error(&path, format!("Failed to get position: {}", e));
394 }
395 }
396 }
397 Err(e) => {
398 result.add_error("<iteration error>", format!("Tree iteration failed: {}", e));
399 }
400 }
401 }
402
403 Ok(result)
404}
405
406/// Collect files from the working copy.
407///

Callers

nothing calls this directly

Calls 7

PristineClass · 0.85
iter_treeMethod · 0.45
is_emptyMethod · 0.45
add_skippedMethod · 0.45
inode_positionMethod · 0.45
addMethod · 0.45
add_errorMethod · 0.45

Tested by

no test coverage detected