From 295602adfe302a28f0e3cbf6c729778d80d3c21a Mon Sep 17 00:00:00 2001 From: iris <2+iris@noreply.localhost> Date: Fri, 28 Aug 2026 18:12:30 -0400 Subject: [PATCH] Save the config through the shared crate as well `Config::save` was the same nine lines as dev-updater's, so it is now `format::write(path, self)`. The reasoning that made those nine lines correct -- the leftover temp file that keeps its old mode and is then renamed over the token hashes -- lives with the code and its test rather than in two places that could stop agreeing. Verified: 35 tests, clippy silent, rustfmt clean. --- server/src/config.rs | 12 ++---------- wg-app-link | 2 +- 2 files changed, 3 insertions(+), 11 deletions(-) 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