From 5c1dd66380b19bf98c7fada63aa91ba2e0acd227 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Tue, 14 Sep 2021 14:33:58 +0200 Subject: [PATCH] Use env var for config location when saving (not default location) --- crates/utils/src/settings/mod.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/utils/src/settings/mod.rs b/crates/utils/src/settings/mod.rs index d47cc5b4b..7e320701d 100644 --- a/crates/utils/src/settings/mod.rs +++ b/crates/utils/src/settings/mod.rs @@ -6,7 +6,7 @@ use std::{env, fs, io::Error, sync::RwLock}; pub mod structs; -static CONFIG_FILE: &str = "config/config.hjson"; +static DEFAULT_CONFIG_FILE: &str = "config/config.hjson"; lazy_static! { static ref SETTINGS: RwLock = @@ -54,7 +54,7 @@ impl Settings { } pub fn get_config_location() -> String { - env::var("LEMMY_CONFIG_LOCATION").unwrap_or_else(|_| CONFIG_FILE.to_string()) + env::var("LEMMY_CONFIG_LOCATION").unwrap_or_else(|_| DEFAULT_CONFIG_FILE.to_string()) } pub fn read_config_file() -> Result { @@ -92,7 +92,7 @@ impl Settings { } pub fn save_config_file(data: &str) -> Result { - fs::write(CONFIG_FILE, data)?; + fs::write(Settings::get_config_location(), data)?; // Reload the new settings // From https://stackoverflow.com/questions/29654927/how-do-i-assign-a-string-to-a-mutable-static-variable/47181804#47181804