Compare commits

..

4 commits

Author SHA1 Message Date
Claude 0672290c4b
docs(audit): log 2026-04-29 findings
https://claude.ai/code/session_01Vk2NBZGFP3YVshDj1CwDjt
2026-04-29 07:12:42 +00:00
Claude 01bd4672c1
refactor(tauri): drop redundant handle clone in start_watcher
start_watcher takes handle: tauri::AppHandle by value, then immediately did let handle = handle.clone() before moving it into the file-watcher closure. The intermediate clone has no purpose: the parameter is unused outside the closure, so the move can take it directly.

https://claude.ai/code/session_01Vk2NBZGFP3YVshDj1CwDjt
2026-04-29 07:12:29 +00:00
Claude 6c0d7257df
refactor(sync): use shared atomic_write in SyncState::save
SyncState::save duplicated the temp+rename+cleanup-on-failure pattern that storage::atomic_write already provides. Replace the inline implementation with a call to atomic_write, completing the consolidation begun for AppConfig::save_to_file and OfflineQueue::save.

https://claude.ai/code/session_01Vk2NBZGFP3YVshDj1CwDjt
2026-04-29 07:11:29 +00:00
Claude 80757345ab
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
2026-04-29 07:11:13 +00:00
3 changed files with 10 additions and 16 deletions

View file

@ -1,5 +1,13 @@
# Audit Log # Audit Log
## 2026-04-29
Found and fixed 3 issues:
1. **Code quality: duplicated atomic-write in `OfflineQueue::save`** (sync.rs:332) — the function maintained its own copy of the temp-file + rename + cleanup-on-failure dance even though `storage::atomic_write` is `pub(crate)` and was already shared by `AppConfig::save_to_file` (fixed 04-25) and `google_tasks.rs`. Replaced the inline implementation with a call to `crate::storage::atomic_write`.
2. **Code quality: duplicated atomic-write in `SyncState::save`** (sync.rs:534) — same pattern as `OfflineQueue::save`. Replaced with a call to `atomic_write`, completing the consolidation of every per-call atomic write into a single shared helper.
3. **Code quality: redundant clone in `start_watcher`** (tauri/lib.rs:1206) — `start_watcher(handle: tauri::AppHandle, ...)` took `handle` by value, then immediately did `let handle = handle.clone();` before moving it into the file-watcher closure. The parameter was unused outside the closure, so the intermediate clone was pure waste. Removed it.
## 2026-04-27 ## 2026-04-27
Found and fixed 3 issues: Found and fixed 3 issues:

View file

@ -1203,7 +1203,6 @@ fn start_watcher(handle: tauri::AppHandle, path: PathBuf) {
if let Ok(mut w) = WATCHER.lock() { if let Ok(mut w) = WATCHER.lock() {
*w = None; *w = None;
} }
let handle = handle.clone();
let debouncer = new_debouncer( let debouncer = new_debouncer(
std::time::Duration::from_millis(500), std::time::Duration::from_millis(500),
move |events: Result<Vec<notify_debouncer_mini::DebouncedEvent>, notify::Error>| { move |events: Result<Vec<notify_debouncer_mini::DebouncedEvent>, notify::Error>| {

View file

@ -341,13 +341,7 @@ impl OfflineQueue {
return Ok(()); return Ok(());
} }
let content = serde_json::to_string_pretty(self)?; let content = serde_json::to_string_pretty(self)?;
// Atomic write: write to temp then rename atomic_write(&queue_path, content.as_bytes())?;
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());
}
Ok(()) Ok(())
} }
@ -534,14 +528,7 @@ impl SyncState {
pub fn save(&self, workspace_path: &Path) -> Result<()> { pub fn save(&self, workspace_path: &Path) -> Result<()> {
let state_path = workspace_path.join(".syncstate.json"); let state_path = workspace_path.join(".syncstate.json");
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 atomic_write(&state_path, content.as_bytes())?;
let temp_path = workspace_path.join(".syncstate.json.tmp");
std::fs::write(&temp_path, &content)?;
if let Err(e) = std::fs::rename(&temp_path, &state_path) {
// Clean up temp file on rename failure to prevent accumulation
let _ = std::fs::remove_file(&temp_path);
return Err(e.into());
}
Ok(()) Ok(())
} }