mirror of
https://github.com/edera-dev/krata.git
synced 2025-08-03 05:10:55 +00:00
feature(config): write default config to config.toml on startup
This commit is contained in:
@ -112,13 +112,13 @@ fn default_network_ipv6_subnet() -> String {
|
|||||||
|
|
||||||
impl DaemonConfig {
|
impl DaemonConfig {
|
||||||
pub async fn load(path: &Path) -> Result<DaemonConfig> {
|
pub async fn load(path: &Path) -> Result<DaemonConfig> {
|
||||||
if path.exists() {
|
if !path.exists() {
|
||||||
let content = fs::read_to_string(path).await?;
|
let config: DaemonConfig = toml::from_str("")?;
|
||||||
let config: DaemonConfig = toml::from_str(&content)?;
|
let content = toml::to_string_pretty(&config)?;
|
||||||
Ok(config)
|
fs::write(&path, content).await?;
|
||||||
} else {
|
|
||||||
fs::write(&path, "").await?;
|
|
||||||
Ok(DaemonConfig::default())
|
|
||||||
}
|
}
|
||||||
|
let content = fs::read_to_string(path).await?;
|
||||||
|
let config: DaemonConfig = toml::from_str(&content)?;
|
||||||
|
Ok(config)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user