[PR #8094] [MERGED] fix(backups): support large full-backup ZIP directories #8097

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/8094
Author: @SpicyMarinara
Created: 10/22/2026
Status: ✅ Merged
Merged: 10/22/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/8089-large-profile-backup-directory


📝 Commits (4)

  • 5191a02 chore: start large profile backup directory fix
  • 63f7f89 fix(backup): bound large full-backup ZIP directories separately
  • b93b5f3 fix(backup): reject oversized ordinary directories during traversal
  • 439143d fix(backups): preflight full directories through bounded read windows

📊 Changes

2 files changed (+326 additions, -88 deletions)

View changed files

📝 packages/server/src/routes/backup.routes.ts (+173 -87)
📝 scripts/regressions/automatic-backup-retention.regression.ts (+153 -1)

📄 Description

Linked issue

Closes #8089

Why this change

A full-profile backup with many nested files can exceed the ordinary 8 MiB ZIP directory limit. Creation then fails after collecting the profile, and the reader cannot restore that archive.

What changed

  • Give full backup creation and structurally validated full backup imports a separate 32 MiB directory limit. Ordinary and native profile exports/imports retain the existing 8 MiB limit, including native exports that allow large payloads.
  • Read directory metadata through a bounded 64 KiB window, expanding only for one filename/extra-field record when required. Local entry headers, ZIP64 values, payload bounds and existing integrity checks remain validated.
  • Before retaining entries from an oversized directory, validate its backup root, unique manifest, last-written restore notes, stored sizes, physical entry order and non-overlapping ranges. Both passes use the same open file handle. This prevents a backup-shaped invalid archive from allocating the larger entry list before rejection.
  • Oversized directories must preserve the physical entry order used by the Engine backup writer. Ordinary archives keep their existing ordering support.
  • Add an 8,193-entry long-path fixture above the old limit, in the real writer's order with deferred RESTORE.txt last. Restore its streamed asset through production staging/promotion and retain ordinary/native export negative controls.

Validation

Local Node 24.22.1 / macOS arm64:

  • pnpm install --frozen-lockfile: passed.
  • Final pnpm check: passed.
  • Backup regressions: 4/4 passed; profile-import regressions: 3/3 passed. The existing open-issues regression also passed earlier in this change.
  • Red/green proof: the large fixture fails on the original writer's 8 MiB ceiling and passes with the full-backup path. Missing restore notes and overlapping ranges are rejected before any entry objects are retained. Disabling the validation pass makes the missing-notes control retain 8,196 entries instead of zero. The valid control retains each entry exactly once.
  • Review findings about the shared native-export caller, delayed classification and fixture/production ordering were reproduced and repaired. The final bounded-window implementation also addresses the local performance finding about per-record directory I/O. Fresh final local CodeRabbit review completed across both changed files with no new findings; its stored earlier performance finding is fixed.

Human verification tasks:

  • Manually create and restore a large full-profile backup in the app.
  • Manually verify native Windows and Android backup/restore behavior.
  • Build/run the container if needed for deployment qualification.

The automated proof uses disposable files. It does not establish browser-driven restoration of a real user profile or physical-device behavior.

Docs and release impact

No user-facing documentation, storage-format or release version changes.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/8094 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/22/2026 **Status:** ✅ Merged **Merged:** 10/22/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/8089-large-profile-backup-directory` --- ### 📝 Commits (4) - [`5191a02`](https://github.com/Pasta-Devs/Marinara-Engine/commit/5191a02578263dd7e4bb8139634a7ae011992cb6) chore: start large profile backup directory fix - [`63f7f89`](https://github.com/Pasta-Devs/Marinara-Engine/commit/63f7f893e2b17da3c48a3eaae7e4e60b9fffbf84) fix(backup): bound large full-backup ZIP directories separately - [`b93b5f3`](https://github.com/Pasta-Devs/Marinara-Engine/commit/b93b5f385ba042d9f1573c990a8552d3c4513d79) fix(backup): reject oversized ordinary directories during traversal - [`439143d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/439143df35f7e5c13585ca9e81b750ba435d8007) fix(backups): preflight full directories through bounded read windows ### 📊 Changes **2 files changed** (+326 additions, -88 deletions) <details> <summary>View changed files</summary> 📝 `packages/server/src/routes/backup.routes.ts` (+173 -87) 📝 `scripts/regressions/automatic-backup-retention.regression.ts` (+153 -1) </details> ### 📄 Description ## Linked issue Closes #8089 ## Why this change A full-profile backup with many nested files can exceed the ordinary 8 MiB ZIP directory limit. Creation then fails after collecting the profile, and the reader cannot restore that archive. ## What changed - Give full backup creation and structurally validated full backup imports a separate 32 MiB directory limit. Ordinary and native profile exports/imports retain the existing 8 MiB limit, including native exports that allow large payloads. - Read directory metadata through a bounded 64 KiB window, expanding only for one filename/extra-field record when required. Local entry headers, ZIP64 values, payload bounds and existing integrity checks remain validated. - Before retaining entries from an oversized directory, validate its backup root, unique manifest, last-written restore notes, stored sizes, physical entry order and non-overlapping ranges. Both passes use the same open file handle. This prevents a backup-shaped invalid archive from allocating the larger entry list before rejection. - Oversized directories must preserve the physical entry order used by the Engine backup writer. Ordinary archives keep their existing ordering support. - Add an 8,193-entry long-path fixture above the old limit, in the real writer's order with deferred RESTORE.txt last. Restore its streamed asset through production staging/promotion and retain ordinary/native export negative controls. ## Validation Local Node 24.22.1 / macOS arm64: - `pnpm install --frozen-lockfile`: passed. - Final `pnpm check`: passed. - Backup regressions: 4/4 passed; profile-import regressions: 3/3 passed. The existing open-issues regression also passed earlier in this change. - Red/green proof: the large fixture fails on the original writer's 8 MiB ceiling and passes with the full-backup path. Missing restore notes and overlapping ranges are rejected before any entry objects are retained. Disabling the validation pass makes the missing-notes control retain 8,196 entries instead of zero. The valid control retains each entry exactly once. - Review findings about the shared native-export caller, delayed classification and fixture/production ordering were reproduced and repaired. The final bounded-window implementation also addresses the local performance finding about per-record directory I/O. Fresh final local CodeRabbit review completed across both changed files with no new findings; its stored earlier performance finding is fixed. Human verification tasks: - [ ] Manually create and restore a large full-profile backup in the app. - [ ] Manually verify native Windows and Android backup/restore behavior. - [ ] Build/run the container if needed for deployment qualification. The automated proof uses disposable files. It does not establish browser-driven restoration of a real user profile or physical-device behavior. ## Docs and release impact No user-facing documentation, storage-format or release version changes. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-24 04:10:21 +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#8097
No description provided.