Merge branch 'main' into patch-1

pull/4604/head
SleeplessOne1917 2 months ago committed by GitHub
commit 58e89f77ca
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -13,8 +13,17 @@ use structs::{DatabaseConnection, PictrsConfig, PictrsImageMode, Settings};
static DEFAULT_CONFIG_FILE: &str = "config/config.hjson";
pub static SETTINGS: Lazy<Settings> = Lazy::new(|| {
Settings::init().expect("Failed to load settings file, see documentation (https://join-lemmy.org/docs/en/administration/configuration.html)")
if env::var("LEMMY_INITIALIZE_WITH_DEFAULT_SETTINGS").is_ok() {
println!(
"LEMMY_INITIALIZE_WITH_DEFAULT_SETTINGS was set, any configuration file has been ignored."
);
println!("Use with other environment variables to configure this instance further; e.g. LEMMY_DATABASE_URL.");
Settings::default()
} else {
Settings::init().expect("Failed to load settings file, see documentation (https://join-lemmy.org/docs/en/administration/configuration.html).")
}
});
static WEBFINGER_REGEX: Lazy<Regex> = Lazy::new(|| {
Regex::new(&format!(
"^acct:([a-zA-Z0-9_]{{3,}})@{}$",
@ -30,9 +39,7 @@ impl Settings {
/// `lemmy_db_schema/src/lib.rs::get_database_url_from_env()`
/// Warning: Only call this once.
pub(crate) fn init() -> Result<Self, LemmyError> {
// Read the config file
let config = from_str::<Settings>(&Self::read_config_file()?)?;
if config.hostname == "unset" {
Err(anyhow!("Hostname variable is not set!").into())
} else {

Loading…
Cancel
Save