This commit is contained in:
SteelDynamite 2026-04-29 08:13:11 +01:00 committed by GitHub
commit 133be6d3b8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 10 additions and 16 deletions

View file

@ -1,5 +1,13 @@
# 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
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() {
*w = None;
}
let handle = handle.clone();
let debouncer = new_debouncer(
std::time::Duration::from_millis(500),
move |events: Result<Vec<notify_debouncer_mini::DebouncedEvent>, notify::Error>| {

View file

@ -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(())
}
@ -534,14 +528,7 @@ impl SyncState {
pub fn save(&self, workspace_path: &Path) -> Result<()> {
let state_path = workspace_path.join(".syncstate.json");
let content = serde_json::to_string_pretty(self)?;
// 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());
}
atomic_write(&state_path, content.as_bytes())?;
Ok(())
}