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