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,
)
| 563 | /// |
| 564 | /// The allocated inode for the file. |
| 565 | pub 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 | /// |