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,
)
| 28 | /// |
| 29 | /// The allocated inode for the file. |
| 30 | pub 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 | /// |