diff options
| author | tslil <tslil@posteo.de> | 2026-07-14 12:20:44 +0100 |
|---|---|---|
| committer | tslil <tslil@posteo.de> | 2026-07-14 13:02:51 +0100 |
| commit | 156cbfe2b0383521f540109682d98d35c88d65f8 (patch) | |
| tree | e4607f60c1c58ad566d2d86488a601d58eee4220 /src/config.rs | |
| parent | 861fb134ad6d77faeb23e9571a31e0c6031d7374 (diff) | |
don't cache album list, use compression only on json for ease of inspection
Diffstat (limited to 'src/config.rs')
| -rw-r--r-- | src/config.rs | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/src/config.rs b/src/config.rs index f38b571..15b449a 100644 --- a/src/config.rs +++ b/src/config.rs @@ -6,7 +6,7 @@ use expanduser::expanduser; #[derive(Serialize, Deserialize)] pub struct Config { - pub music_roots: Vec<String>, + pub music_root: String, pub audio_exts: Vec<String>, pub skip_window_secs: u64, pub temperature: f32, @@ -19,7 +19,7 @@ pub struct Config { fn default_config_path() -> String { let name = "mood.json"; ProjectDirs::from("qualifier", "organisation", "mood") - .and_then(|pd| pd.config_dir().join(name).to_str().map(|x| x.to_string())) + .and_then(|pd| pd.config_dir().join(name).to_str().map(std::string::ToString::to_string)) .unwrap_or(format!("~/.config/mood/{name}")) } @@ -35,8 +35,8 @@ impl Config { let path = expanduser(default_config_path()).map_err(|e| e.to_string())?; _ = path.parent().map(std::fs::create_dir_all); let serialised = serde_json::to_string_pretty(self) - .map_err(|e| format!("Failed to serialize config: {}", e))?; - fs::write(&path, serialised).map_err(|e| format!("Failed to write config file: {}", e))?; + .map_err(|e| format!("Failed to serialize config: {e}"))?; + fs::write(&path, serialised).map_err(|e| format!("Failed to write config file: {e}"))?; Ok(()) } } @@ -44,14 +44,12 @@ impl Config { impl Default for Config { fn default() -> Config { Config { - music_roots: vec![ - UserDirs::new() - .and_then(|u| { - u.audio_dir() - .and_then(|p| p.to_str().map(|x| x.to_string())) - }) - .unwrap_or("~/Music".to_string()), - ], + music_root: UserDirs::new() + .and_then(|u| { + u.audio_dir() + .and_then(|p| p.to_str().map(std::string::ToString::to_string)) + }) + .unwrap_or("~/Music".to_string()), audio_exts: [".mp3", ".flac", ".wav", ".m4a", ".ogg", ".vorbis"] .into_iter() .map(String::from) |
