Skip to content

SnapshotService::cleanup_stale_snapshots() is never called — aionui-snapshot-* dirs accumulate in %TEMP% forever #737

Description

@beee9

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions