Skip to content

Commit

Permalink
fix crash when trying to open a folder that has since been deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
edwloef committed Dec 14, 2024
1 parent 5533212 commit 79f5259
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/folder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,11 @@ where
}

fn init_children(&self) -> Vec<Element<'a, Message, Theme, Renderer>> {
let mut files: Vec<_> = std::fs::read_dir(&self.path)
.unwrap()
let Ok(files) = std::fs::read_dir(&self.path) else {
return vec![];
};

let mut files: Vec<_> = files
.filter_map(Result::ok)
.map(|file| {
let mut name = file.file_name();
Expand Down Expand Up @@ -293,7 +296,6 @@ where
<= state.line_height.get().unwrap()
{
state.open ^= true;
self.children.get_or_init(|| self.init_children());
self.diff(tree);
shell.invalidate_layout();
return Status::Captured;
Expand Down

0 comments on commit 79f5259

Please sign in to comment.