mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #2402] [MERGED] Clean up NPC avatar files on re-upload and chat delete #5584
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#5584
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/2402
Author: @Romuromylus
Created: 6/6/2026
Status: ✅ Merged
Merged: 6/6/2026
Merged by: @Romuromylus
Base:
refactor← Head:fix/npc-avatar-cleanup📝 Commits (1)
1bbdbc9Clean up NPC avatar files on re-upload and chat delete📊 Changes
2 files changed (+72 additions, -0 deletions)
View changed files
📝
src-tauri/src/commands/storage/avatars.rs(+68 -0)📝
src-tauri/src/commands/storage/chats.rs(+4 -0)📄 Description
Linked issue
Closes #2329
Why this change
avatars/npc/{chatId}-{name}-{millis}.{ext}) leaked two ways: every regen wrote a fresh timestamped file without removing the prior one, and chat deletion never swept them. NPC avatars live inline in chat metadata (gameNpcs/presentCharacters), not as tracked records, so no managed-file cleanup hook ever fired. Pure disk accumulation (low severity, no correctness impact).What changed
src-tauri/src/commands/storage/avatars.rs:update_npc_avatarnow removes older files for the same chat+name that the regen superseded, keeping only the just-written file (mirrorsupdate_character_avatar_inner's prior-file cleanup). Matching usessafe_filename("{chat_id}-{name}")+-delimiter so "Rin" can't match "Rina", and excludes the kept filename by exact name.src-tauri/src/commands/storage/chats.rs:delete_chat_with_messagesbest-effort scansavatars/npc/by deleted{chat_id}-prefix (chat ids are UUIDs), mirroringdelete_gallery_for_chats.Refactor impact
Primary owner: Rust storage
Impact areas reviewed:
src-tauri/src/commands/storage/avatars.rs(update_npc_avatar+ new prefix-scan helpers)src-tauri/src/commands/storage/chats.rs(delete_chat_with_messages)Boundary notes:
Pressure points touched:
Validation
pnpm checkpasses before PR push/handoffManual verification notes
cargo test --manifest-path src-tauri/Cargo.toml -p marinara-engine(npc_avatar / delete_chat filters) — pass; existing avatar/gallery/delete tests stay green. Local-only tests confirmed re-upload removes the prior file, preserves a different name, and chat delete removes the chat's NPC avatars.cargo clippy --manifest-path src-tauri/Cargo.toml --workspace --all-targets -- -D warnings— clean.Feature Discoverability
src/features/shell/discovery/Reason:
Docs and release impact
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.