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

Function add_to_tree

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

Add a single file to tracking. This is the low-level function that actually modifies the database. It does NOT check if the file exists on disk or is already tracked. # Arguments `txn` - A mutable transaction `path` - The normalized path string `is_directory` - Whether this is a directory # Returns The allocated inode for the file.

(
    txn: &mut T,
    path: &str,
    is_directory: bool,
)

Source from the content-addressed store, hash-verified

563///
564/// The allocated inode for the file.
565pub fn add_to_tree<T: MutTxnT>(
566 txn: &mut T,
567 path: &str,
568 is_directory: bool,
569) -> TrackingResult<Inode> {
570 // Allocate a new inode
571 let inode = txn
572 .alloc_inode()
573 .map_err(|e| TrackingError::Database(e.to_string()))?;
574
575 let kind = if is_directory {
576 TreeProjectionKind::Directory
577 } else {
578 TreeProjectionKind::File
579 };
580 TreeProjectionPlan::plan(
581 txn,
582 [TreeProjectionOperation::Add {
583 inode,
584 path: Some(path.to_string()),
585 position: None,
586 kind,
587 }],
588 )?
589 .apply(txn)?;
590
591 Ok(inode)
592}
593
594/// Add an empty directory to tracking explicitly.
595///

Callers 10

addMethod · 0.85
test_add_and_get_inodeFunction · 0.85
test_move_tracked_fileFunction · 0.85
test_list_tracked_filesFunction · 0.85

Calls 3

planFunction · 0.85
alloc_inodeMethod · 0.45
applyMethod · 0.45