mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #2115] [MERGED] Fix storage deletion & cleanup correctness #5443
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#5443
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/2115
Author: @kolacheee
Created: 6/4/2026
Status: ✅ Merged
Merged: 6/4/2026
Merged by: @Xelvanis
Base:
refactor← Head:fix/storage-deletion-correctness📝 Commits (3)
63acd16Ignore local .pnpm-store/ and per-user .claude settingsb7a1e03Fix storage deletion & cleanup correctness (#2114)58c2e8dRevert stale swipe-cleanup change; add avatarPath regression test📊 Changes
3 files changed (+151 additions, -6 deletions)
View changed files
📝
.gitignore(+4 -0)📝
src-tauri/src/commands/storage/avatars.rs(+76 -4)📝
src-tauri/src/commands/storage/chats.rs(+71 -2)📄 Description
Linked issue
Closes #2114
Why this change
bulk_delete_messagescould delete messages belonging to a different chat) and one MEDIUM (persona-avatar reference detection missedavatarPath). The other two were investigated and found not to hold for the actual code paths, and are left unchanged with the reasoning recorded below.What changed
chats.rsbulk_delete_messages— the pre-scan only confirmed each id exists, never that it belongs tochat_id, so a caller passing message ids from another chat would destroy them (and their swipe sidecars). Now filtered bychatId == chat_id(mirrors the existing gallery-cleanup pattern). Regression test added.avatars.rs— the "is this persona avatar still referenced by a message snapshot?" scan only inspectedsnapshot.avatarUrl. A snapshot referencing the avatar viaavatarPath(oravatar) looked unused, risking its file being cleaned up. Now checksavatarUrl/avatarPath/avatar. Regression test added.Findings investigated and left unchanged (stale — code already correct):
DeleteMessageTrackerSnapshotsonly) and concluded deleting a message orphans itsmessage-swipessidecar rows. It does not.delete_entityroutes every message deletion throughmessage_swipes::delete_message_rows_with_swipes, which atomically removes the message row and its swipe sidecars in one transaction — asserted by the existing testdelete_message_rows_with_swipes_replaces_parent_and_sidecar_together.apply_delete_cleanupruns after that atomic delete, and there is no code path that deletes a message row while skipping the helper (apply_delete_cleanuphas a single caller). ADeleteMessageSwipescleanup would therefore be a redundant no-op — it callsdelete_for_messages, which uses the identicalsidecar_message_idmatching and can only ever find 0 remaining rows. Left unchanged.activeSwipeIndex— the finding suggested the projection should addactiveSwipeIndexforcontent/characterId.activeSwipeIndexis a deliberate internal sidecar field excluded fromcontent-only projections — asserted bymessage_projection_materialization_includes_internal_sort_fields— and active-swipe content materializes through theextra/swipespath. Adding it breaks that tested contract, so the finding does not hold for this design.Refactor impact
Primary owner: Rust storage / capability layer (
src-tauri/src/commands/storage)Impact areas reviewed:
chats.rs(bulk message delete) andavatars.rs(persona-snapshot avatar reference scan). No frontend changes.Boundary notes:
chatIdfilter; the persona-snapshot URL-field scan) rather than adding a parallel path.Pressure points touched:
src-tauristorage commands only. No storage-collection contract (contracts.rs) or delete-cleanup dispatch (commands/entities.rs) change, and nosrc-tauri/src/lib.rscommand-registration change.Validation
pnpm typecheck,pnpm build,pnpm check:architecture,pnpm check:docs, or fullpnpm checkwhen warranted)pnpm checkpasses before PR push/handoffManual verification notes
cargo test --manifest-path src-tauri/Cargo.toml --lib→ 451 passed, 0 failed (includes both new regression tests — bulk-delete cross-chat and the persona-avataravatarPathscan — plus the full existing storage suite, e.g. the swipe-projection materialization tests and the atomic message+sidecar delete test).Feature Discoverability
src/features/shell/discovery/because this PR adds or materially changes a user-discoverable feature, workflow, setting, mode, panel, import path, agent, media capability, or advanced tool.Reason:
Docs and release impact
README.mdCONTRIBUTING.mddocs/developer/AGENTS.mdProof
Core claim:
avatarPath/avatar-referenced avatars — each backed by a dedicated regression test, with the existing active-swipe projection and atomic message+sidecar delete contracts preserved unchanged.Verification run:
cargo test --manifest-path src-tauri/Cargo.toml --lib→ 451 passed / 0 failed.Evidence:
bulk_delete_messages_ignores_ids_from_another_chat: with one message inchat-1and one inchat-2,bulk_delete_messages(chat-1, [both ids])reportsdeleted == 1, removes thechat-1message, and leaves thechat-2message intact.persona_avatar_update_preserves_snapshot_referenced_by_avatar_path: a message snapshot references the persona avatar only viaavatarPath(noavatarUrl, no matchingavatarFilePath), so preservation must come from the broadened URL-field scan rather than the file-path fallback; after re-uploading the persona avatar, the originally-referenced managed file still exists.delete_message_rows_with_swipes_replaces_parent_and_sidecar_together— stays green, confirming the two fixes and both dismissed findings don't regress existing behavior.Risk coverage:
avatarPath-referenced avatar is counted as referenced and its file preserved.Manual verification requested:
UI evidence (if applicable)
N/A — backend storage-layer fix with no visible UI change.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.