perf(storage): offload file pruning to background thread

Moves the synchronous file I/O logic in `run_backups` to a background thread (`std:🧵:spawn`) so that deleting old snapshots or deleted-sheets files does not block the main thread execution.

Co-authored-by: Horizontal42 <75383519+Horizontal42@users.noreply.github.com>
This commit is contained in:
google-labs-jules[bot] 2026-08-09 10:09:45 +00:00
parent c958f30662
commit 28a66562a2

View file

@ -477,6 +477,8 @@ fn run_backups(app: AppHandle, dir: Option<String>, retention_days: u32) -> Resu
})
.collect();
snaps.sort();
std::thread::spawn(move || {
if snaps.len() > SNAPSHOT_KEEP {
for old in &snaps[..snaps.len() - SNAPSHOT_KEEP] {
fs::remove_file(old).ok();
@ -495,6 +497,8 @@ fn run_backups(app: AppHandle, dir: Option<String>, retention_days: u32) -> Resu
}
}
}
});
Ok(())
}