From 80757345abbd61600c677cd5f19b183904df59d3 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 29 Apr 2026 07:11:13 +0000 Subject: [PATCH] refactor(sync): use shared atomic_write in OfflineQueue::save OfflineQueue::save had its own copy of the temp-file + rename + cleanup-on-failure dance, even though the storage::atomic_write helper is pub(crate) and already used by AppConfig::save_to_file and google_tasks. Replace the inline implementation with a call to atomic_write so the crate has one canonical atomic write path. https://claude.ai/code/session_01Vk2NBZGFP3YVshDj1CwDjt --- crates/onyx-core/src/sync.rs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/crates/onyx-core/src/sync.rs b/crates/onyx-core/src/sync.rs index 6bb626d..7d50be7 100644 --- a/crates/onyx-core/src/sync.rs +++ b/crates/onyx-core/src/sync.rs @@ -341,13 +341,7 @@ impl OfflineQueue { return Ok(()); } let content = serde_json::to_string_pretty(self)?; - // Atomic write: write to temp then rename - let temp_path = workspace_path.join(".syncqueue.json.tmp"); - std::fs::write(&temp_path, &content)?; - if let Err(e) = std::fs::rename(&temp_path, &queue_path) { - let _ = std::fs::remove_file(&temp_path); - return Err(e.into()); - } + atomic_write(&queue_path, content.as_bytes())?; Ok(()) }