Skip to content

Commit

Permalink
Fix for Windows config directory bug (#554)
Browse files Browse the repository at this point in the history
  • Loading branch information
jacksongoode authored Nov 9, 2024
1 parent 0292319 commit 5fb8918
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 7 deletions.
31 changes: 31 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions psst-gui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ log = { version = "0.4.22" }
lru = { version = "0.12.5" }
once_cell = { version = "1.20.2" }
parking_lot = { version = "0.12.3" }
platform-dirs = { version = "0.3.0" }
rand = { version = "0.8.5" }
regex = { version = "1.11.0" }
serde = { version = "1.0.210", features = ["derive", "rc"] }
Expand Down
16 changes: 9 additions & 7 deletions psst-gui/src/data/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use std::{
#[cfg(target_family = "unix")]
use std::os::unix::fs::OpenOptionsExt;

use directories::ProjectDirs;
use druid::{Data, Lens, Size};
use platform_dirs::AppDirs;
use psst_core::{
cache::mkdir_if_not_exists,
connection::Credentials,
Expand Down Expand Up @@ -125,23 +125,25 @@ impl Default for Config {
}

impl Config {
fn project_dirs() -> Option<ProjectDirs> {
ProjectDirs::from("", "", APP_NAME)
fn app_dirs() -> Option<AppDirs> {
const USE_XDG_ON_MACOS: bool = false;

AppDirs::new(Some(APP_NAME), USE_XDG_ON_MACOS)
}

pub fn spotify_local_files_file(username: &str) -> Option<PathBuf> {
ProjectDirs::from("", "", "spotify").map(|dirs| {
AppDirs::new(Some("spotify"), false).map(|dir| {
let path = format!("Users/{}-user/local-files.bnk", username);
dirs.config_dir().join(path)
dir.config_dir.join(path)
})
}

pub fn cache_dir() -> Option<PathBuf> {
Self::project_dirs().map(|dirs| dirs.cache_dir().to_path_buf())
Self::app_dirs().map(|dirs| dirs.cache_dir)
}

pub fn config_dir() -> Option<PathBuf> {
Self::project_dirs().map(|dirs| dirs.config_dir().to_path_buf())
Self::app_dirs().map(|dirs| dirs.config_dir)
}

fn config_path() -> Option<PathBuf> {
Expand Down

0 comments on commit 5fb8918

Please sign in to comment.