fixed mpd crash caused by unwraping

This commit is contained in:
mustafa salih 2021-01-12 06:36:48 +03:00
parent 066b38dd71
commit 7a47332cec
3 changed files with 9 additions and 3 deletions

2
Cargo.lock generated
View File

@ -397,7 +397,7 @@ checksum = "4e1b7878800220a76a08f32c057829511440f65528b63b940f2f2bc145d7ac68"
[[package]]
name = "rsblocks"
version = "0.1.6"
version = "0.1.8"
dependencies = [
"alsa",
"breadx",

View File

@ -1,6 +1,6 @@
[package]
name = "rsblocks"
version = "0.1.6"
version = "0.1.8"
authors = ["mustafa salih <mustafasalih1991@gmail.com>"]
edition = "2018"
readme = "README.md"

View File

@ -770,7 +770,13 @@ pub fn get_mpd_current(config: &Config) -> String {
Ok(connection) => connection,
_ => return String::from(""),
};
let current: Song = conn.currentsong().unwrap().unwrap();
let current: Song = match conn.currentsong() {
Ok(opt) => match opt {
Some(song) => song,
_ => return String::from(""),
},
_ => return String::from(""),
};
let result = format!(
" {} {} {}",