Skip to content

Commit

Permalink
Don't create config dir for server in default location if not needed (#…
Browse files Browse the repository at this point in the history
…406)

...respect ATUIN_CONFIG_DIR.

The current behaviour is problematic when running atuin server as a
system service with config dir in /etc/atuin.
  • Loading branch information
jirutka authored May 13, 2022
1 parent b7946cc commit 5e4e8d1
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions atuin-server/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,11 @@ pub struct Settings {

impl Settings {
pub fn new() -> Result<Self> {
let config_dir = atuin_common::utils::config_dir();
let config_dir = config_dir.as_path();

create_dir_all(config_dir)?;

let mut config_file = if let Ok(p) = std::env::var("ATUIN_CONFIG_DIR") {
PathBuf::from(p)
} else {
let mut config_file = PathBuf::new();
let config_dir = atuin_common::utils::config_dir();
config_file.push(config_dir);
config_file
};
Expand All @@ -50,6 +46,7 @@ impl Settings {
))
} else {
let example_config = include_bytes!("../server.toml");
create_dir_all(config_file.parent().unwrap())?;
let mut file = File::create(config_file)?;
file.write_all(example_config)?;

Expand Down

0 comments on commit 5e4e8d1

Please sign in to comment.