From efabb036317a6d57d29f2ae782fddb44963edd44 Mon Sep 17 00:00:00 2001 From: Sasha Hilton Date: Sun, 24 Jan 2021 23:21:35 +0000 Subject: [PATCH] Fix incorrect cache initialisation causing crash on startup --- src/main.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main.rs b/src/main.rs index 4d3c4f40..4f80657e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -254,18 +254,18 @@ fn setup(args: &[String]) -> Setup { mapped_volume: !matches.opt_present("mixer-linear-volume"), }; - let use_audio_cache = !matches.opt_present("disable-audio-cache"); + let cache = matches.opt_str("c").map(|cache_path| { + let use_audio_cache = !matches.opt_present("disable-audio-cache"); + let system_cache_directory = matches + .opt_str("system-cache") + .unwrap_or(String::from(cache_path.clone())); - let cache_directory = matches.opt_str("c").unwrap_or(String::from("")); - let system_cache_directory = matches - .opt_str("system-cache") - .unwrap_or(String::from(cache_directory.clone())); - - let cache = Some(Cache::new( - PathBuf::from(cache_directory), - PathBuf::from(system_cache_directory), - use_audio_cache, - )); + Cache::new( + PathBuf::from(cache_path), + PathBuf::from(system_cache_directory), + use_audio_cache, + ) + }); let initial_volume = matches .opt_str("initial-volume")