MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / insert_tree_pair

Function insert_tree_pair

atomic-repository/src/repository/repair.rs:1603–1634  ·  view source on GitHub ↗
(
    tree: &mut BTreeMap<String, Inode>,
    reverse: &mut BTreeMap<Inode, String>,
    path: &str,
    inode: Inode,
)

Source from the content-addressed store, hash-verified

1601}
1602
1603fn insert_tree_pair(
1604 tree: &mut BTreeMap<String, Inode>,
1605 reverse: &mut BTreeMap<Inode, String>,
1606 path: &str,
1607 inode: Inode,
1608) -> Result<(), RepositoryError> {
1609 if let Some(previous) = tree.insert(path.to_string(), inode) {
1610 if previous != inode {
1611 return Err(RepositoryError::InvalidOperation {
1612 message: format!(
1613 "native projection maps '{}' to both inode {} and inode {}",
1614 path,
1615 previous.get(),
1616 inode.get()
1617 ),
1618 });
1619 }
1620 }
1621 if let Some(previous) = reverse.insert(inode, path.to_string()) {
1622 if previous != path {
1623 return Err(RepositoryError::InvalidOperation {
1624 message: format!(
1625 "native projection maps inode {} to both '{}' and '{}'",
1626 inode.get(),
1627 previous,
1628 path
1629 ),
1630 });
1631 }
1632 }
1633 Ok(())
1634}
1635
1636fn parent_path(path: &str) -> Option<&str> {
1637 path.rsplit_once('/').map(|(parent, _)| parent)

Callers 1

Calls 1

insertMethod · 0.45

Tested by

no test coverage detected