From 7a47332cec4f833e9ba03cfd8653a9f0462c5bec Mon Sep 17 00:00:00 2001 From: mustafa salih Date: Tue, 12 Jan 2021 06:36:48 +0300 Subject: [PATCH] fixed mpd crash caused by unwraping --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/lib.rs | 8 +++++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a168dae..ff50eb5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -397,7 +397,7 @@ checksum = "4e1b7878800220a76a08f32c057829511440f65528b63b940f2f2bc145d7ac68" [[package]] name = "rsblocks" -version = "0.1.6" +version = "0.1.8" dependencies = [ "alsa", "breadx", diff --git a/Cargo.toml b/Cargo.toml index 1c7f856..d80267d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rsblocks" -version = "0.1.6" +version = "0.1.8" authors = ["mustafa salih "] edition = "2018" readme = "README.md" diff --git a/src/lib.rs b/src/lib.rs index 6a29067..d417164 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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!( " {} {} {}",