(
txn: &T,
store: &C,
inode: Inode,
visibility: &GraphVisibilityClosure,
)
| 1373 | } |
| 1374 | |
| 1375 | pub(super) fn has_visible_span_root<T, C>( |
| 1376 | txn: &T, |
| 1377 | store: &C, |
| 1378 | inode: Inode, |
| 1379 | visibility: &GraphVisibilityClosure, |
| 1380 | ) -> Result<bool, RepositoryError> |
| 1381 | where |
| 1382 | T: atomic_core::pristine::span_patch_storage::SpanPatchReadTxn |
| 1383 | + atomic_core::pristine::TreeTxnT |
| 1384 | + atomic_core::pristine::CapabilityTxnT, |
| 1385 | C: atomic_core::change::ChangeStore, |
| 1386 | { |
| 1387 | use atomic_core::pristine::SPAN_RANGE_CAPABILITY; |
| 1388 | let capability = txn |
| 1389 | .required_capability_version(SPAN_RANGE_CAPABILITY.id()) |
| 1390 | .map_err(|error| RepositoryError::Database(error.to_string()))?; |
| 1391 | let Some(root) = txn |
| 1392 | .span_root(inode) |
| 1393 | .map_err(|error| RepositoryError::Database(error.to_string()))? |
| 1394 | else { |
| 1395 | if capability.is_some() { |
| 1396 | let position = txn |
| 1397 | .inode_position(inode) |
| 1398 | .map_err(|error| RepositoryError::Database(error.to_string()))?; |
| 1399 | if let Some(position) = position.filter(|position| !position.change.is_root()) { |
| 1400 | let hash = txn |
| 1401 | .get_external(position.change) |
| 1402 | .map_err(|error| RepositoryError::Database(error.to_string()))? |
| 1403 | .ok_or_else(|| { |
| 1404 | RepositoryError::Database("file origin hash is missing".into()) |
| 1405 | })?; |
| 1406 | let origin = store |
| 1407 | .get_change(&hash) |
| 1408 | .map_err(|error| RepositoryError::Database(error.to_string()))?; |
| 1409 | if origin.hashed.span.is_some() { |
| 1410 | return Err(RepositoryError::Database(format!( |
| 1411 | "span root missing for inode {}", |
| 1412 | inode.get() |
| 1413 | ))); |
| 1414 | } |
| 1415 | } |
| 1416 | } |
| 1417 | use atomic_core::pristine::SPAN_LEGACY_CONTEXT_CAPABILITY; |
| 1418 | return match txn |
| 1419 | .required_capability_version(SPAN_LEGACY_CONTEXT_CAPABILITY.id()) |
| 1420 | .map_err(|e| RepositoryError::Database(e.to_string()))? |
| 1421 | { |
| 1422 | None => { |
| 1423 | if !txn |
| 1424 | .span_edits_for_inode(inode) |
| 1425 | .map_err(|e| RepositoryError::Database(e.to_string()))? |
| 1426 | .is_empty() |
| 1427 | { |
| 1428 | return Err(RepositoryError::Database( |
| 1429 | "legacy span index has no matching repository capability".into(), |
| 1430 | )); |
| 1431 | } |
| 1432 | Ok(false) |
no test coverage detected