[GH-ISSUE #2330] [Issue]: Sprite cleanup restore-points accumulate unbounded with no cap or cleanup path #1157

Closed
opened 2026-10-21 05:28:04 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @Romuromylus on GitHub (Jun 5, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2330

Originally assigned to: @Xelvanis on GitHub.

Summary

Severity: Low — Disk leak. Each "Clean saved sprites" run creates a .cleanup-restore-points/<millis>-<id>/ directory holding a full copy of every cleaned sprite plus a manifest. These are only deleted on a fully-successful restore of that exact point; there is no cap and no UI to list/clear them, so the common iterate-cleanup workflow leaves a full duplicate sprite set on disk after every run.

Expected behavior

Retained restore points should be capped (keep the most recent N, prune older), and/or there should be a way to clear them.

Actual behavior

src-tauri/src/commands/storage/sprites.rs:462-514 (clean_saved_sprites):

let restore_point_id = format!("{}-{}", now_millis(), new_id());
let restore_point_dir = dir.join(".cleanup-restore-points").join(&restore_point_id);
fs::create_dir_all(&restore_point_dir)?; // never pruned; only removed on a clean restore

Each run copies every cleaned sprite into the new dir (line 480). The dir is removed inline only if nothing was cleaned (503-504), or on a fully-successful restore of that exact id (restore_sprite_cleanup_point, 593-595). A repo-wide grep finds .cleanup-restore-points referenced only at sprites.rs:463/:540 — no mtime prune, no N-cap, no clear command. The UI (CharacterSpritesTab.tsx) tracks only a single lastCleanupRestorePointId in component state, overwritten each run (so prior runs' dirs become unreferenced) and reset on unmount. These dirs are excluded from profile export (collect_profile_assets skips dot-prefixed names), so this is a local-disk-only leak.

Steps to reproduce

  1. Run "Clean saved sprites" / background removal on a character's sprites several times without restoring.
  2. Each run leaves a permanent .cleanup-restore-points/<id> folder with a copy of every sprite.

Impact area

  • Catalog resources
  • Tauri/Rust storage, assets, LLM, integrations, security, imports, or HTTP runtime

Environment

  • Branch or commit: refactor @ b0e5561d
  • Run mode: Tauri desktop (also server mode)
  • OS + version: not relevant (static source audit)
  • Node + pnpm versions: not relevant
  • Rust version, if relevant: not relevant
  • Remote Runtime URL configured? not relevant (applies to both)
  • Provider, model, or integration, if relevant: sprite cleanup feature

Logs, screenshots, or video

Static source audit; cited to file:line above.

Regression notes

Found via static audit of the refactor branch; not verified against main. Local-disk-only, bounded per run, grows only as fast as the user re-runs cleanup, hence low.

Additional context

Suggested fix: at the start of clean_saved_sprites, enumerate .cleanup-restore-points/ subdirs and prune all but the most recent N by the <millis> prefix (or by mtime); and/or expose a clear-restore-points command + UI.

Template check

Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @Romuromylus on GitHub (Jun 5, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2330 Originally assigned to: @Xelvanis on GitHub. ## Summary **Severity: Low — Disk leak.** Each "Clean saved sprites" run creates a `.cleanup-restore-points/<millis>-<id>/` directory holding a full copy of every cleaned sprite plus a manifest. These are only deleted on a fully-successful restore of that exact point; there is no cap and no UI to list/clear them, so the common iterate-cleanup workflow leaves a full duplicate sprite set on disk after every run. ## Expected behavior Retained restore points should be capped (keep the most recent N, prune older), and/or there should be a way to clear them. ## Actual behavior `src-tauri/src/commands/storage/sprites.rs:462-514` (`clean_saved_sprites`): ```rust let restore_point_id = format!("{}-{}", now_millis(), new_id()); let restore_point_dir = dir.join(".cleanup-restore-points").join(&restore_point_id); fs::create_dir_all(&restore_point_dir)?; // never pruned; only removed on a clean restore ``` Each run copies every cleaned sprite into the new dir (line 480). The dir is removed inline only if nothing was cleaned (503-504), or on a fully-successful restore of that exact id (`restore_sprite_cleanup_point`, 593-595). A repo-wide grep finds `.cleanup-restore-points` referenced only at `sprites.rs:463`/`:540` — no mtime prune, no N-cap, no clear command. The UI (`CharacterSpritesTab.tsx`) tracks only a single `lastCleanupRestorePointId` in component state, overwritten each run (so prior runs' dirs become unreferenced) and reset on unmount. These dirs are excluded from profile export (`collect_profile_assets` skips dot-prefixed names), so this is a local-disk-only leak. ## Steps to reproduce 1. Run "Clean saved sprites" / background removal on a character's sprites several times without restoring. 2. Each run leaves a permanent `.cleanup-restore-points/<id>` folder with a copy of every sprite. ## Impact area - [x] Catalog resources - [x] Tauri/Rust storage, assets, LLM, integrations, security, imports, or HTTP runtime ## Environment - Branch or commit: refactor @ b0e5561d - Run mode: Tauri desktop (also server mode) - OS + version: not relevant (static source audit) - Node + pnpm versions: not relevant - Rust version, if relevant: not relevant - Remote Runtime URL configured? not relevant (applies to both) - Provider, model, or integration, if relevant: sprite cleanup feature ## Logs, screenshots, or video Static source audit; cited to file:line above. ## Regression notes Found via static audit of the refactor branch; not verified against main. Local-disk-only, bounded per run, grows only as fast as the user re-runs cleanup, hence low. ## Additional context Suggested fix: at the start of `clean_saved_sprites`, enumerate `.cleanup-restore-points/` subdirs and prune all but the most recent N by the `<millis>` prefix (or by mtime); and/or expose a clear-restore-points command + UI. ## Template check Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:28:04 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#1157
No description provided.