Feat: Ergänzt storage-Struktur in Konfigurationsmodul und implementiert Default-Wert sowie Konfigurationsspeicherung
This commit is contained in:
@@ -20,6 +20,8 @@ pub struct AppConfig {
|
|||||||
pub local: Local,
|
pub local: Local,
|
||||||
/// Remote-Einbindungseinstellungen
|
/// Remote-Einbindungseinstellungen
|
||||||
pub remote: Remote,
|
pub remote: Remote,
|
||||||
|
/// Lokaler Zwischenspeicher
|
||||||
|
pub storage: Option<Storage>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for AppConfig {
|
impl Default for AppConfig {
|
||||||
@@ -28,6 +30,7 @@ impl Default for AppConfig {
|
|||||||
general: General::default(),
|
general: General::default(),
|
||||||
local: Local::default(),
|
local: Local::default(),
|
||||||
remote: Remote::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.
|
/// Ermittelt den Standard-Einhängepunkt basierend auf dem Betriebssystem.
|
||||||
fn get_default_mount_path() -> String {
|
fn get_default_mount_path() -> String {
|
||||||
#[cfg(not(any(target_os = "windows")))]
|
#[cfg(not(any(target_os = "windows")))]
|
||||||
@@ -136,12 +153,12 @@ fn load_config() -> AppConfig {
|
|||||||
confy::load(&*program::program_name(), CONFIG_NAME).unwrap_or_default()
|
confy::load(&*program::program_name(), CONFIG_NAME).unwrap_or_default()
|
||||||
}
|
}
|
||||||
|
|
||||||
// /// Speichert die übergebene Konfiguration in der Konfigurationsdatei.
|
/// Speichert die übergebene Konfiguration in der Konfigurationsdatei.
|
||||||
// fn save_config(config: AppConfig) {
|
fn save_config(config: AppConfig) {
|
||||||
// #[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
// if is_run_as_root() {
|
if is_run_as_root() {
|
||||||
// confy::store_path(format!("/etc/{}/{}.toml", program::program_name(), CONFIG_NAME), config).unwrap();
|
confy::store_path(format!("/etc/{}/{}.toml", program::program_name(), CONFIG_NAME), config).unwrap();
|
||||||
// return;
|
return;
|
||||||
// }
|
}
|
||||||
// confy::store(&*program::program_name(), CONFIG_NAME, config).unwrap();
|
confy::store(&*program::program_name(), CONFIG_NAME, config).unwrap();
|
||||||
// }
|
}
|
||||||
Reference in New Issue
Block a user