Skip to content

Commit

Permalink
handle errs in dir_entries_from_path
Browse files Browse the repository at this point in the history
Signed-off-by: simonsan <[email protected]>
  • Loading branch information
simonsan committed Mar 17, 2024
1 parent c87e9f6 commit f1218c8
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions crates/core/src/vfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,23 +364,28 @@ impl Vfs {
let result = match self.tree.get_path(path)? {
VfsPath::RusticPath(tree_id, path) => {
let node = repo.node_from_path(*tree_id, &path)?;
if node.is_dir() {
let tree = repo.get_tree(&node.subtree.unwrap())?;
if node.is_dir() && node.subtree.is_some() {
let Some(id) = node.subtree else {
return Err(
VfsErrorKind::NoDirectoryEntriesForSymlinkFound(path.into()).into()

Check warning on line 370 in crates/core/src/vfs.rs

View check run for this annotation

Codecov / codecov/patch

crates/core/src/vfs.rs#L367-L370

Added lines #L367 - L370 were not covered by tests
);
};
let tree = repo.get_tree(&id)?;

Check warning on line 373 in crates/core/src/vfs.rs

View check run for this annotation

Codecov / codecov/patch

crates/core/src/vfs.rs#L373

Added line #L373 was not covered by tests
tree.nodes
} else {
Vec::new()
}
}
VfsPath::VirtualTree(virtual_tree) => virtual_tree
.iter()
.map(|(name, tree)| {
.map(|(name, tree)| -> RusticResult<_> {

Check warning on line 381 in crates/core/src/vfs.rs

View check run for this annotation

Codecov / codecov/patch

crates/core/src/vfs.rs#L381

Added line #L381 was not covered by tests
let node_type = match tree {
VfsTree::Link(target) => NodeType::from_link(Path::new(target)),
_ => NodeType::Dir,
};
Node::from_type_and_metadata(name, node_type, Metadata::default())

Check warning on line 386 in crates/core/src/vfs.rs

View check run for this annotation

Codecov / codecov/patch

crates/core/src/vfs.rs#L386

Added line #L386 was not covered by tests
})
.collect(),
.collect::<RusticResult<Vec<Node>>>()?,
VfsPath::Link(str) => {
return Err(VfsErrorKind::NoDirectoryEntriesForSymlinkFound(str.clone()).into());
}
Expand Down

0 comments on commit f1218c8

Please sign in to comment.