Compare commits
No commits in common. "claude/serene-ride-Q8TVl" and "main" have entirely different histories.
claude/ser
...
main
8
Audit.md
8
Audit.md
|
|
@ -1,13 +1,5 @@
|
||||||
# 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:
|
||||||
|
|
|
||||||
|
|
@ -1203,6 +1203,7 @@ 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>| {
|
||||||
|
|
|
||||||
|
|
@ -341,7 +341,13 @@ impl OfflineQueue {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
let content = serde_json::to_string_pretty(self)?;
|
let content = serde_json::to_string_pretty(self)?;
|
||||||
atomic_write(&queue_path, content.as_bytes())?;
|
// 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());
|
||||||
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -528,7 +534,14 @@ 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(&state_path, content.as_bytes())?;
|
// Atomic write: write to temp file then rename to prevent corruption on crash
|
||||||
|
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(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue