(
txn: &T,
store: &C,
inode: Inode,
visibility: &GraphVisibilityClosure,
)
| 1221 | } |
| 1222 | |
| 1223 | pub(super) fn has_visible_span_root<T, C>( |
| 1224 | txn: &T, |
| 1225 | store: &C, |
| 1226 | inode: Inode, |
| 1227 | visibility: &GraphVisibilityClosure, |
| 1228 | ) -> Result<bool, RepositoryError> |
| 1229 | where |
| 1230 | T: atomic_core::pristine::span_patch_storage::SpanPatchReadTxn |
| 1231 | + atomic_core::pristine::TreeTxnT |
| 1232 | + atomic_core::pristine::CapabilityTxnT, |
| 1233 | C: atomic_core::change::ChangeStore, |
| 1234 | { |
| 1235 | use atomic_core::pristine::SPAN_RANGE_CAPABILITY; |
| 1236 | let capability = txn |
| 1237 | .required_capability_version(SPAN_RANGE_CAPABILITY.id()) |
| 1238 | .map_err(|error| RepositoryError::Database(error.to_string()))?; |
| 1239 | let Some(root) = txn |
| 1240 | .span_root(inode) |
| 1241 | .map_err(|error| RepositoryError::Database(error.to_string()))? |
| 1242 | else { |
| 1243 | if capability.is_some() { |
| 1244 | let position = txn |
| 1245 | .inode_position(inode) |
| 1246 | .map_err(|error| RepositoryError::Database(error.to_string()))?; |
| 1247 | if let Some(position) = position.filter(|position| !position.change.is_root()) { |
| 1248 | let hash = txn |
| 1249 | .get_external(position.change) |
| 1250 | .map_err(|error| RepositoryError::Database(error.to_string()))? |
| 1251 | .ok_or_else(|| { |
| 1252 | RepositoryError::Database("file origin hash is missing".into()) |
| 1253 | })?; |
| 1254 | let origin = store |
| 1255 | .get_change(&hash) |
| 1256 | .map_err(|error| RepositoryError::Database(error.to_string()))?; |
| 1257 | if origin.hashed.span.is_some() { |
| 1258 | return Err(RepositoryError::Database(format!( |
| 1259 | "span root missing for inode {}", |
| 1260 | inode.get() |
| 1261 | ))); |
| 1262 | } |
| 1263 | } |
| 1264 | } |
| 1265 | return Ok(false); |
| 1266 | }; |
| 1267 | if !matches!(capability, Some(2) | Some(3)) { |
| 1268 | return Err(RepositoryError::Database( |
| 1269 | "span index has no matching repository capability".into(), |
| 1270 | )); |
| 1271 | } |
| 1272 | if !visibility.contains(NodeId::new(root[0])) { |
| 1273 | return Err(RepositoryError::Database( |
| 1274 | "span root is outside the requested view".into(), |
| 1275 | )); |
| 1276 | } |
| 1277 | Ok(true) |
| 1278 | } |
| 1279 | |
| 1280 | pub(crate) fn retrieve_content_with_filter_fast<T, C>( |
no test coverage detected