From 00a22ae9d96d181ab36447b2e68683e36d3b2e1e Mon Sep 17 00:00:00 2001 From: DragonSlayer_14 Date: Thu, 21 Aug 2025 14:26:31 +0200 Subject: [PATCH] =?UTF-8?q?Feat:=20Erg=C3=A4nzt=20`storage`-Struktur=20in?= =?UTF-8?q?=20Konfigurationsmodul=20und=20implementiert=20Default-Wert=20s?= =?UTF-8?q?owie=20Konfigurationsspeicherung?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config.rs | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/src/config.rs b/src/config.rs index 5ba7775..6a0d00f 100644 --- a/src/config.rs +++ b/src/config.rs @@ -20,6 +20,8 @@ pub struct AppConfig { pub local: Local, /// Remote-Einbindungseinstellungen pub remote: Remote, + /// Lokaler Zwischenspeicher + pub storage: Option, } impl Default for AppConfig { @@ -28,6 +30,7 @@ impl Default for AppConfig { general: General::default(), local: Local::default(), remote: Remote::default(), + storage: None, } } } @@ -95,6 +98,20 @@ impl Default for Remote { } } +/// Zwischenspeicher für das Programm. +#[derive(Serialize, Deserialize, Clone)] +pub struct Storage { + pub device_ip: String, +} + +impl Default for Storage { + fn default() -> Self { + Self { + device_ip: "".to_string(), + } + } +} + /// Ermittelt den Standard-Einhängepunkt basierend auf dem Betriebssystem. fn get_default_mount_path() -> String { #[cfg(not(any(target_os = "windows")))] @@ -136,12 +153,12 @@ fn load_config() -> AppConfig { confy::load(&*program::program_name(), CONFIG_NAME).unwrap_or_default() } -// /// Speichert die übergebene Konfiguration in der Konfigurationsdatei. -// fn save_config(config: AppConfig) { -// #[cfg(target_os = "linux")] -// if is_run_as_root() { -// confy::store_path(format!("/etc/{}/{}.toml", program::program_name(), CONFIG_NAME), config).unwrap(); -// return; -// } -// confy::store(&*program::program_name(), CONFIG_NAME, config).unwrap(); -// } \ No newline at end of file +/// Speichert die übergebene Konfiguration in der Konfigurationsdatei. +fn save_config(config: AppConfig) { + #[cfg(target_os = "linux")] + if is_run_as_root() { + confy::store_path(format!("/etc/{}/{}.toml", program::program_name(), CONFIG_NAME), config).unwrap(); + return; + } + confy::store(&*program::program_name(), CONFIG_NAME, config).unwrap(); +} \ No newline at end of file