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

Function add_directory_to_tree

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

Add an empty directory to tracking explicitly. This is distinct from `add_to_tree` because it specifically handles empty directories that need to be tracked even without children. The directory will be marked with `DIR_EXPLICIT | DIR_EMPTY` flags. # Arguments `txn` - A mutable transaction `path` - The normalized directory path # Returns The allocated inode for the directory. # Example ```ru

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

Source from the content-addressed store, hash-verified

79/// txn.commit()?;
80/// ```
81pub fn add_directory_to_tree<T: MutTxnT>(txn: &mut T, path: &str) -> TrackingResult<Inode> {
82 // Allocate a new inode
83 let inode = txn
84 .alloc_inode()
85 .map_err(|e| TrackingError::Database(e.to_string()))?;
86
87 // Add to tree tables
88 txn.put_tree(path, inode)
89 .map_err(|e| TrackingError::Database(e.to_string()))?;
90
91 // Mark as an explicit empty directory
92 txn.put_directory(inode, directory_flags::explicit_empty())
93 .map_err(|e| TrackingError::Database(e.to_string()))?;
94
95 Ok(inode)
96}
97
98/// Check if an inode represents a directory.
99///

Callers 1

add_directoryMethod · 0.85

Calls 4

explicit_emptyFunction · 0.85
put_treeMethod · 0.80
put_directoryMethod · 0.80
alloc_inodeMethod · 0.45

Tested by

no test coverage detected