iOfficeAI / iOfficeAI/AionCore
SnapshotService::cleanup_stale_snapshots() is never called — aionui-snapshot-* dirs accumulate in %TEMP% forever
- Dominant language
- Rust
- Stars
- 105
- Forks
- 169
- Avg merge
- 5h 58m
- Merged PRs (30d)
- 84
Description
## Bug description
SnapshotService::cleanup_stale_snapshots() exists in
crates/aionui-file/src/snapshot_service/mod.rs (with the doc comment
"Call once at application startup"), but it is never called anywhere in
the codebase. Leftover aionui-snapshot-* directories in the system temp
dir therefore accumulate forever.
### Impact
On Windows (and any OS), every server start creates a new snapshot dir.
Because temp_repo_path() uses DefaultHasher (random per-process seed),
the generated dir name differs on every run, so the "clean up same-name old
dir" logic in init_snapshot_repo() never matches a previous run's dir.
When a process exits non-cleanly (crash / kill), the snapshot dir is left
behind and is never removed. Users can lose multiple GB of C: drive space
over time.
### Steps to reproduce
1. Start aioncore server.
2. Trigger a workspace snapshot (file snapshot API).
3. Kill the process without graceful shutdown.
4. Repeat a few times.
5. %TEMP%\aionui-snapshot-* dirs keep piling up and are never cleaned.
### Expected behavior
Stale aionui-snapshot-* dirs are removed when the application starts
(as the doc comment of cleanup_stale_snapshots() intends).
## Proposed fix
Call SnapshotService::cleanup_stale_snapshots() once in the server
startup path in crates/aionui-app/src/main.rs, None => arm of
async_main, after bootstrap::init_environment(...) (after the
data-dir instance guard is acquired), before serving.
Patch:
// crates/aionui-app/src/main.rs
None => {
let mut env = bootstrap::init_environment(&cli, &merged_path)?;
// Remove leftover aionui-snapshot-* dirs from previous runs that
// did not exit cleanly (the snapshot service only cleans up on
// graceful shutdown).
aionui_file::SnapshotService::cleanup_stale_snapshots();
// Acquire the data-dir process-level guard before binding a port
...
}
Note: please verify aionui_file is a dependency of aionui-app
(otherwise add it to Cargo.toml), or place the call where
SnapshotService is constructed.
## Workaround for existing installs
Until a fixed build ships, a scheduled task can run the equivalent cleanup
daily:
powershell
$tempDir = [System.IO.Path]::GetTempPath()
$cutoff = (Get-Date).AddDays(-1)
Get-ChildItem -Path $tempDir -Directory -Filter "aionui-snapshot-*" |
Where-Object { $_.LastWriteTime -lt $cutoff } |
Remove-Item -Recurse -Force
## Environment
- AionCore version: v0.1.52 (bundled with AionUi)
- OS: Windows x86_64
Contributor guide
No contributing guide indexed for this repository
Research direction
Read crates/aionui-file/src/snapshot_service/mod.rs and the None => startup arm in crates/aionui-app/src/main.rs. Verify whether aionui-file is available to aionui-app, then add the startup call after bootstrap::init_environment(...) and before serving. Done means stale aionui-snapshot-* directories are cleaned during server startup without disrupting initialization.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 82/100