mirror of
https://github.com/arabianq/pipewire-soundpad.git
synced 2026-04-28 06:21:23 +00:00
fix: handle errors when opening a directory in SoundpadGui
This commit is contained in:
+12
-6
@@ -110,12 +110,18 @@ impl SoundpadGui {
|
|||||||
|
|
||||||
pub fn open_dir(&mut self, path: &PathBuf) {
|
pub fn open_dir(&mut self, path: &PathBuf) {
|
||||||
self.app_state.current_dir = Some(path.clone());
|
self.app_state.current_dir = Some(path.clone());
|
||||||
self.app_state.files = path
|
match path.read_dir() {
|
||||||
.read_dir()
|
Ok(read_dir) => {
|
||||||
.unwrap()
|
self.app_state.files = read_dir
|
||||||
.filter_map(|res| res.ok())
|
.filter_map(|res| res.ok())
|
||||||
.map(|entry| entry.path())
|
.map(|entry| entry.path())
|
||||||
.collect();
|
.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) {
|
pub fn play_file(&mut self, path: &PathBuf, concurrent: bool) {
|
||||||
|
|||||||
Reference in New Issue
Block a user