refactor(config): reuse storage::atomic_write for save_to_file

`AppConfig::save_to_file` had its own copy of the temp-file + rename +
cleanup-on-failure dance.  `storage::atomic_write` is already
`pub(crate)` and does exactly that — `google_tasks.rs` was migrated to
use it earlier.  Drop the duplicate so there's one canonical atomic
write path in the crate.
This commit is contained in:
Claude 2026-04-25 07:27:25 +00:00
parent 069afe8d5e
commit 8c8735b2b4
No known key found for this signature in database

View file

@ -116,13 +116,7 @@ impl AppConfig {
std::fs::create_dir_all(parent)?; std::fs::create_dir_all(parent)?;
} }
let content = serde_json::to_string_pretty(&self)?; let content = serde_json::to_string_pretty(&self)?;
// Atomic write: write to temp file then rename to prevent corruption on crash crate::storage::atomic_write(path, content.as_bytes())?;
let temp = path.with_extension("tmp");
std::fs::write(&temp, &content)?;
if let Err(e) = std::fs::rename(&temp, path) {
let _ = std::fs::remove_file(&temp);
return Err(e.into());
}
Ok(()) Ok(())
} }