Skip to content

Commit

Permalink
Use XDGBDS by default
Browse files Browse the repository at this point in the history
  • Loading branch information
boaz-quotient committed Apr 7, 2023
1 parent 74d8a5b commit f6ec8c6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
7 changes: 6 additions & 1 deletion shellclear/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ pub struct Config {

impl Default for Config {
fn default() -> Self {
Self::with_custom_path(&dirs::home_dir().unwrap())
let config = Self::with_custom_path(&dirs::home_dir().unwrap());
if Path::new(&config.sensitive_commands_path).exists() {
config
} else {
Self::with_custom_path(&dirs::config_dir().unwrap())
}
}
}

Expand Down
6 changes: 3 additions & 3 deletions shellclear/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ pub struct ShellContext {
///
/// Will return `Err` when has en create a dir problem
pub fn init() -> Result<Vec<ShellContext>> {
let homedir = match dirs::home_dir() {
let state_dir_path = match dirs::cache_dir().or_else(dirs::home_dir) {
Some(h) => h.display().to_string(),
None => return Err(anyhow!("could not get directory path")),
};

// create a application folder to save all the temp data
let state_folder = Path::new(&homedir)
let state_folder = Path::new(&state_dir_path)
.join(STATE_FOLDER_NAME)
.display()
.to_string();
Expand All @@ -53,7 +53,7 @@ pub fn init() -> Result<Vec<ShellContext>> {
debug!("state created in path: {:?}", state_folder);
}

Ok(shell::get_all_history_files(&homedir)
Ok(shell::get_all_history_files(&dirs::home_dir().unwrap().display().to_string())
.iter()
.map(|h| ShellContext {
app_folder_path: state_folder.clone(),
Expand Down

0 comments on commit f6ec8c6

Please sign in to comment.