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:622–643  ·  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

620/// txn.commit()?;
621/// ```
622pub fn add_directory_to_tree<T: MutTxnT>(txn: &mut T, path: &str) -> TrackingResult<Inode> {
623 // Allocate a new inode
624 let inode = txn
625 .alloc_inode()
626 .map_err(|e| TrackingError::Database(e.to_string()))?;
627
628 TreeProjectionPlan::plan(
629 txn,
630 [
631 TreeProjectionOperation::Add {
632 inode,
633 path: Some(path.to_string()),
634 position: None,
635 kind: TreeProjectionKind::Directory,
636 },
637 TreeProjectionOperation::DirectoryOccupancy { inode, empty: true },
638 ],
639 )?
640 .apply(txn)?;
641
642 Ok(inode)
643}
644
645/// Check if an inode represents a directory.
646///

Callers 1

add_directoryMethod · 0.85

Calls 3

planFunction · 0.85
alloc_inodeMethod · 0.45
applyMethod · 0.45

Tested by

no test coverage detected