| 260 | } |
| 261 | |
| 262 | fn validated_primary<T: TreeTxnT>( |
| 263 | txn: &T, |
| 264 | path: &str, |
| 265 | ) -> Result<Option<Inode>, TreeProjectionError> { |
| 266 | let Some(primary) = txn |
| 267 | .get_inode(path) |
| 268 | .map_err(|error| TreeProjectionError::Database(error.to_string()))? |
| 269 | else { |
| 270 | return Ok(None); |
| 271 | }; |
| 272 | let reverse = txn |
| 273 | .get_path(primary) |
| 274 | .map_err(|error| TreeProjectionError::Database(error.to_string()))?; |
| 275 | if reverse.as_deref() != Some(path) { |
| 276 | return Err(TreeProjectionError::IncompleteMetadata(format!( |
| 277 | "TREE maps '{}' to inode {}, but its REV_TREE row is {:?}", |
| 278 | path, |
| 279 | primary.get(), |
| 280 | reverse |
| 281 | ))); |
| 282 | } |
| 283 | Ok(Some(primary)) |
| 284 | } |
| 285 | |
| 286 | fn validate<T: TreeTxnT + PathClaimTxnT>(&self, txn: &T) -> Result<(), TreeProjectionError> { |
| 287 | txn.validate_tree_bijection() |