Skip to content

Commit 307dade

Browse files
committed
Make previous changes backwards-compatible
Depending on the existence of the original config location, uses it or the new location This prevents the backwards-incompatible change at the cost of some checking on every config query.
1 parent 5caa7a1 commit 307dade

File tree

1 file changed

+11
-3
lines changed
  • spotify_player/src/config

1 file changed

+11
-3
lines changed

spotify_player/src/config/mod.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
mod keymap;
22
mod theme;
33

4+
const DEFAULT_CONFIG_FOLDER: &str = ".config/spotify-player";
45
const APP_CONFIG_FILE: &str = "app.toml";
56
const THEME_CONFIG_FILE: &str = "theme.toml";
67
const KEYMAP_CONFIG_FILE: &str = "keymap.toml";
@@ -323,10 +324,17 @@ const APP_NAME: &str = "spotify-player";
323324

324325
/// gets the application's configuration folder path
325326
pub fn get_config_folder_path() -> Result<PathBuf> {
326-
match dirs_next::config_dir() {
327-
Some(config_home) => Ok(config_home.join(APP_NAME)),
328-
None => Err(anyhow!("cannot find the $HOME folder")),
327+
if let Some(home) = dirs_next::home_dir() {
328+
let old_path = home.join(DEFAULT_CONFIG_FOLDER);
329+
if old_path.exists() {
330+
return Ok(old_path);
331+
}
329332
}
333+
if let Some(config_home) = dirs_next::config_dir() {
334+
return Ok(config_home.join(APP_NAME));
335+
}
336+
337+
Err(anyhow!("cannot find the $HOME folder"))
330338
}
331339

332340
/// gets the application's cache folder path

0 commit comments

Comments
 (0)