diff --git a/backend/sync_server/src/app_state.rs b/backend/sync_server/src/app_state.rs index b17963b8..0e1ff9f8 100644 --- a/backend/sync_server/src/app_state.rs +++ b/backend/sync_server/src/app_state.rs @@ -9,9 +9,9 @@ pub struct AppState { impl AppState { pub async fn try_new() -> Result { - let path = std::path::Path::new(CONFIG_PATH).canonicalize()?; + let path = std::path::Path::new(CONFIG_PATH); - let config = Config::read(&path).await?; + let config = Config::read_or_create(path).await?; let database = Database::try_new(&config.database).await?; Ok(Self { config, database }) diff --git a/backend/sync_server/src/config.rs b/backend/sync_server/src/config.rs index 8ecbc23e..0aa7ae92 100644 --- a/backend/sync_server/src/config.rs +++ b/backend/sync_server/src/config.rs @@ -23,14 +23,20 @@ pub struct Config { } impl Config { - pub async fn read(path: &Path) -> Result { + pub async fn read_or_create(path: &Path) -> Result { if path.exists() { - info!("Loading configuration from {path:?}"); + info!( + "Loading configuration from {:?}", + path.canonicalize().unwrap() + ); Self::load_from_file(path).await } else { - warn!("Configuration file not found, writing default configuration to {path:?}"); let config = Config::default(); config.write(path).await?; + warn!( + "Configuration file not found, wrote default configuration to {:?}", + path.canonicalize().unwrap() + ); Ok(config) } }