From 7ef1c7a5a1540412b7d16c6104d56004b69de795 Mon Sep 17 00:00:00 2001 From: Sachin Iyer Date: Fri, 8 May 2026 20:04:30 -0700 Subject: [PATCH] refactor(config): remove dead save_config function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Drop save_config and its dedicated round-trip test. The function had no production callers — the only references were two #[cfg(test)] sites in the same file. Closes Detail bug bug_3b5a0cd5 / GH issue #269 (truncate- before-lock race in save_config) by removing the function rather than fixing the race. The concurrent_update_config_does_not_corrupt test now seeds the config file with update_config(|_| {}) instead. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/config/storage.rs | 31 ++----------------------------- 1 file changed, 2 insertions(+), 29 deletions(-) diff --git a/src/config/storage.rs b/src/config/storage.rs index 112a5b0..2c90b96 100644 --- a/src/config/storage.rs +++ b/src/config/storage.rs @@ -64,16 +64,6 @@ pub fn load_config() -> Result { toml::from_str(&contents).context("Failed to parse config") } -pub fn save_config(config: &Config) -> Result<()> { - let path = config_path()?; - let contents = toml::to_string_pretty(config)?; - let file = File::create(&path)?; - file.lock_exclusive()?; - (&file).write_all(contents.as_bytes())?; - file.unlock()?; - Ok(()) -} - /// Atomically read-modify-write the config file under an exclusive lock. /// /// Preserves comments and formatting the user may have added by hand. The @@ -262,24 +252,7 @@ mod tests { }); } - // ── save / load round-trip ─────────────────────────────────────── - - #[test] - fn save_then_load_config() { - with_temp_config(|| { - let config = Config { - api_url: Some("https://test.dev".into()), - app_url: None, - check_for_updates: true, - last_update_check: None, - api_token: Some("tok".into()), - }; - save_config(&config).unwrap(); - let loaded = load_config().unwrap(); - assert_eq!(loaded.api_url.as_deref(), Some("https://test.dev")); - assert_eq!(loaded.api_token.as_deref(), Some("tok")); - }); - } + // ── load_config ────────────────────────────────────────────────── #[test] fn load_config_partial_file_defaults_check_for_updates() { @@ -492,7 +465,7 @@ api_token = \"old_token\" with_temp_config(|| { // Initialize config - save_config(&Config::default()).unwrap(); + update_config(|_| {}).unwrap(); let handles: Vec<_> = (0..10) .map(|i| {