mirror of
https://github.com/Horizontal42/summarum.git
synced 2026-11-11 01:02:01 +03:00
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:
parent
c958f30662
commit
28a66562a2
1 changed files with 18 additions and 14 deletions
|
|
@ -477,6 +477,8 @@ fn run_backups(app: AppHandle, dir: Option<String>, retention_days: u32) -> Resu
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
snaps.sort();
|
snaps.sort();
|
||||||
|
|
||||||
|
std::thread::spawn(move || {
|
||||||
if snaps.len() > SNAPSHOT_KEEP {
|
if snaps.len() > SNAPSHOT_KEEP {
|
||||||
for old in &snaps[..snaps.len() - SNAPSHOT_KEEP] {
|
for old in &snaps[..snaps.len() - SNAPSHOT_KEEP] {
|
||||||
fs::remove_file(old).ok();
|
fs::remove_file(old).ok();
|
||||||
|
|
@ -495,6 +497,8 @@ fn run_backups(app: AppHandle, dir: Option<String>, retention_days: u32) -> Resu
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue