From a6c82e16cc61652292d112dccf15db88846f2759 Mon Sep 17 00:00:00 2001 From: WillKirkmanM Date: Sat, 21 Dec 2024 22:16:12 +0000 Subject: [PATCH] Feat(config.rs): Libraries Location File --- crates/backend/src/utils/config.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/crates/backend/src/utils/config.rs b/crates/backend/src/utils/config.rs index 8501ff01..2d462163 100644 --- a/crates/backend/src/utils/config.rs +++ b/crates/backend/src/utils/config.rs @@ -133,6 +133,26 @@ pub fn get_config_path() -> PathBuf { path } +pub fn get_libraries_config_path() -> PathBuf { + let path = if is_docker() { + Path::new("/ParsonLabsMusic/Config/libraries.json").to_path_buf() + } else { + let mut path = dirs::data_local_dir().unwrap_or_else(|| PathBuf::from(".")); + path.push("ParsonLabs"); + path.push("Music"); + path.push("Config"); + path.push("libraries.json"); + path + }; + + if let Some(parent) = path.parent() { + if let Err(e) = fs::create_dir_all(parent) { + eprintln!("Failed to create directories: {}", e); + } + } + + path +} #[get("/has_config")] async fn has_config() -> impl Responder {