mirror of
https://github.com/arabianq/pipewire-soundpad.git
synced 2026-04-27 22:11:22 +00:00
🧹 Fix unsafe unwrap on file path conversion in CLI and GUI
Replaced `.to_str().unwrap()` with `.to_string_lossy()` when converting `PathBuf` to `String` to prevent potential crashes if the path contains invalid Unicode. This change improves the robustness of both the CLI and GUI components when handling file paths. - Modified `src/bin/cli.rs` to safely handle `file_path`. - Modified `src/gui/mod.rs` to safely handle `path` in `play_file`. Co-authored-by: arabianq <55220741+arabianq@users.noreply.github.com>
This commit is contained in:
+1
-1
@@ -144,7 +144,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
|
||||
Actions::Play {
|
||||
file_path,
|
||||
concurrent,
|
||||
} => Request::play(file_path.to_str().unwrap(), concurrent),
|
||||
} => Request::play(&file_path.to_string_lossy(), concurrent),
|
||||
Actions::ToggleLoop { id } => Request::toggle_loop(id),
|
||||
},
|
||||
Commands::Get { parameter } => match parameter {
|
||||
|
||||
+1
-1
@@ -113,7 +113,7 @@ impl SoundpadGui {
|
||||
}
|
||||
|
||||
pub fn play_file(&mut self, path: &PathBuf, concurrent: bool) {
|
||||
make_request_async(Request::play(path.to_str().unwrap(), concurrent));
|
||||
make_request_async(Request::play(&path.to_string_lossy(), concurrent));
|
||||
}
|
||||
|
||||
pub fn set_input(&mut self, name: String) {
|
||||
|
||||
Reference in New Issue
Block a user