From 5db16c2355e621025ec0db98ec3ace5b042eea5b Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Tue, 28 Oct 2025 09:56:52 +0100 Subject: [PATCH] Make clients list file configurable --- src/data/app_config.rs | 20 +++++++++++++++++--- src/data/client.rs | 2 +- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/data/app_config.rs b/src/data/app_config.rs index 461f009..67b1ac9 100644 --- a/src/data/app_config.rs +++ b/src/data/app_config.rs @@ -18,6 +18,14 @@ pub struct AppConfig { #[clap(short, long, env)] pub storage_path: String, + /// Overwrite clients list file path, if the file is not to be found in storage path + #[clap(long, env)] + pub clients_list_file_path: Option, + + /// Overwrite providers list file path, if the file is not to be found in storage path + #[clap(long, env)] + pub providers_list_file_path: Option, + /// App token token #[clap(short, long, env, default_value = "")] pub token_key: String, @@ -32,7 +40,7 @@ pub struct AppConfig { /// IP location service API /// - /// Up instance of IP location service : https://gitlab.com/pierre42100/iplocationserver + /// Operating instance of IP location service : https://gitlab.com/pierre42100/iplocationserver /// /// Example: "https://api.geoip.rs" #[arg(long, short, env)] @@ -71,11 +79,17 @@ impl AppConfig { } pub fn clients_file(&self) -> PathBuf { - self.storage_path().join(CLIENTS_LIST_FILE) + match &self.clients_list_file_path { + None => self.storage_path().join(CLIENTS_LIST_FILE), + Some(p) => Path::new(p).to_path_buf(), + } } pub fn providers_file(&self) -> PathBuf { - self.storage_path().join(PROVIDERS_LIST_FILE) + match &self.providers_list_file_path { + None => self.storage_path().join(PROVIDERS_LIST_FILE), + Some(p) => Path::new(p).to_path_buf(), + } } pub fn full_url(&self, uri: &str) -> String { diff --git a/src/data/client.rs b/src/data/client.rs index 2271f91..71516e2 100644 --- a/src/data/client.rs +++ b/src/data/client.rs @@ -125,7 +125,7 @@ impl Client { pub type ClientManager = EntityManager; -impl EntityManager { +impl ClientManager { pub fn find_by_id(&self, u: &ClientID) -> Option { for entry in self.iter() { if entry.id.eq(u) {