diff --git a/server/src/config.rs b/server/src/config.rs index d1d2696..5250f3d 100644 --- a/server/src/config.rs +++ b/server/src/config.rs @@ -22,7 +22,7 @@ use std::path::{Path, PathBuf}; use anyhow::{Context, Result}; use serde::{Deserialize, Serialize}; -use wg_app_link::{format, private}; +use wg_app_link::format; #[derive(Debug, Clone, Default, Serialize, Deserialize)] #[serde(rename_all = "camelCase", default)] @@ -434,15 +434,7 @@ impl Config { /// The mode is set on the temporary file *before* the rename, so the /// config is never briefly world-readable at its real path. pub fn save(&self, path: &Path) -> Result<()> { - if let Some(parent) = path.parent() { - private::create_dir(parent)?; - } - let text = format::render(self).context("serialize config")?; - let tmp = path.with_extension("ron.tmp"); - private::write_file(&tmp, text.as_bytes())?; - std::fs::rename(&tmp, path) - .with_context(|| format!("replace {} with {}", path.display(), tmp.display()))?; - Ok(()) + format::write(path, self) } } diff --git a/wg-app-link b/wg-app-link index 4de8bff..db4552f 160000 --- a/wg-app-link +++ b/wg-app-link @@ -1 +1 @@ -Subproject commit 4de8bff5f27640a161e5548affb41214ddb2455a +Subproject commit db4552f4e45cb332bd12a38caeb2373cadf8a48a