1
1
mirror of https://github.com/ellie/atuin.git synced 2024-11-09 00:04:56 +03:00

Don't create config dir for server in default location if not needed (#406)

...respect ATUIN_CONFIG_DIR.

The current behaviour is problematic when running atuin server as a
system service with config dir in /etc/atuin.
This commit is contained in:
Jakub Jirutka 2022-05-13 07:07:46 +02:00 committed by GitHub
parent b7946cc9cb
commit 5e4e8d1152
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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
};
@ -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)?;