Skip to content

Commit

Permalink
Look in data_dir first
Browse files Browse the repository at this point in the history
  • Loading branch information
jtschuster committed May 5, 2024
1 parent 19ceff1 commit 9a77fba
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -643,9 +643,15 @@ impl Settings {

// Use ~/.mcfly only if it already exists, otherwise create 'mcfly' folder in XDG_DATA_DIR
pub fn mcfly_db_path() -> PathBuf {
let data_dir = Settings::mcfly_xdg_dir().data_local_dir().to_path_buf();

Settings::mcfly_base_path(data_dir).join(PathBuf::from("history.db"))
let data_dir = Settings::mcfly_xdg_dir().data_dir().to_path_buf();
if data_dir.exists()
{
return Settings::mcfly_base_path(data_dir).join(PathBuf::from("history.db"));
};

let data_local_dir = Settings::mcfly_xdg_dir().data_local_dir().to_path_buf();
Settings::mcfly_base_path(data_local_dir).join(PathBuf::from("history.db"))
}

// Use ~/.mcfly only if it already exists, otherwise create 'mcfly' folder in XDG_DATA_DIR
Expand Down

0 comments on commit 9a77fba

Please sign in to comment.