fix: handle errors when opening a directory in SoundpadGui

This commit is contained in:
2026-01-28 21:44:00 +03:00
parent 6f35ab7b8b
commit f1d4ffd7fa
+12 -6
View File
@@ -110,12 +110,18 @@ impl SoundpadGui {
pub fn open_dir(&mut self, path: &PathBuf) {
self.app_state.current_dir = Some(path.clone());
self.app_state.files = path
.read_dir()
.unwrap()
.filter_map(|res| res.ok())
.map(|entry| entry.path())
.collect();
match path.read_dir() {
Ok(read_dir) => {
self.app_state.files = read_dir
.filter_map(|res| res.ok())
.map(|entry| entry.path())
.collect();
}
Err(e) => {
eprintln!("Failed to read directory {:?}: {}", path, e);
self.app_state.files.clear();
}
}
}
pub fn play_file(&mut self, path: &PathBuf, concurrent: bool) {