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

Function add_to_tree

atomic-repository/src/tracking/tree_ops.rs:30–51  ·  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

28///
29/// The allocated inode for the file.
30pub fn add_to_tree<T: MutTxnT>(
31 txn: &mut T,
32 path: &str,
33 is_directory: bool,
34) -> TrackingResult<Inode> {
35 // Allocate a new inode
36 let inode = txn
37 .alloc_inode()
38 .map_err(|e| TrackingError::Database(e.to_string()))?;
39
40 // Add to tree tables
41 txn.put_tree(path, inode)
42 .map_err(|e| TrackingError::Database(e.to_string()))?;
43
44 // If this is a directory, mark it in the DIRECTORIES table
45 if is_directory {
46 txn.put_directory(inode, directory_flags::DIR_EXPLICIT)
47 .map_err(|e| TrackingError::Database(e.to_string()))?;
48 }
49
50 Ok(inode)
51}
52
53/// Add an empty directory to tracking explicitly.
54///

Callers 9

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

Calls 3

put_treeMethod · 0.80
put_directoryMethod · 0.80
alloc_inodeMethod · 0.45

Tested by 7

test_add_and_get_inodeFunction · 0.68
test_move_tracked_fileFunction · 0.68
test_list_tracked_filesFunction · 0.68