mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2469] [Issue]: Profile backup import replaces entire managed asset directories, deleting user files absent from the import #1214
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#1214
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?
Originally created by @Romuromylus on GitHub (Jun 6, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2469
Originally assigned to: @SpicyMarinara on GitHub.
Summary
Severity: Medium — data-loss regression. A profile backup import replaces entire managed asset directories (avatars, sprites, backgrounds, gallery, game-assets, fonts, knowledge-sources, lorebooks/images), so any file the user has on disk that is not in the imported archive is permanently deleted. Main merges per-file and never removes pre-existing files.
Expected behavior
Importing a profile backup should merge assets per file — write/overwrite the files in the archive and leave the user's other existing files untouched (main's behavior). If a full-replace is genuinely intended, it should be gated behind an explicit "this replaces all your avatars/sprites/…" confirmation.
Actual behavior
install_innerrenames every existing managed dir to a backup, moves in only the staged dirs, then deletes the backup on commit:So importing a backup that contains even one avatar wipes all of the user's pre-existing avatars; and a managed dir not present in the import at all is still destroyed. The repo's own test
profile_asset_restore_replaces_managed_asset_dirs(:1094-1153) asserts thatavatars/stale.pngandbackgrounds/nested/stale.jpgare gone after an import that did not contain them — confirming this is the live behavior.Steps to reproduce
.zip(or JSON) backup that contains a subset of those (e.g. one avatar, no backgrounds).Impact area
Environment
1fae2c42Logs, screenshots, or video
Static trace + existing test:
profile/assets.rs:176-211(install/commit), testprofile_asset_restore_replaces_managed_asset_dirsat:1094-1153.Regression notes
Regression vs main.
packages/server/src/routes/backup.routes.tsimportProfileStorageSnapshotwrites each asset individually (mkdir(dirname, {recursive}); writeFile(outputPath, buffer)) with norm/whole-dir clear, so pre-existing files survive an import. The refactor's whole-dir replace destroys them.Additional context
A full-backup round-trip is lossless (the export carries all current assets), so the loss is scoped to partial/older/trimmed backups imported into a populated data dir — hence Medium, not High. Fix: stage individual files and rename/copy each onto its target path (mkdir parents), scoping the transactional backup/rollback to the individual written files; or gate the full-replace behind explicit confirmation.
Template check
Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked:
@Romuromylus commented on GitHub (Jun 6, 2026):
Related profile backup/restore safety gaps worth tackling together: #2477 (the same
profile/assets.rsrestore path has only a per-entry size cap, no aggregate/entry-count cap) and #2481 (the backup archive also ships rawapiKeyEncryptedindata/collections/connections.json). Same export/import surface, samewrite_backup_payload/restore flow.@SpicyMarinara commented on GitHub (Jun 6, 2026):
Fixed on refactor in
038b7220.Profile asset import now installs managed assets per file from staging instead of replacing entire managed asset directories, preserving unrelated existing files.
Verification: pnpm typecheck; pnpm build; pnpm check:architecture; cargo check --manifest-path src-tauri/Cargo.toml --workspace; focused Rust backup/profile tests; git diff --check; no .test.ts/.test.tsx files present.