mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #6088] [MERGED] fix(backup): check free space before writing the automatic backup #7056
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#7056
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/6088
Author: @SonaGat3
Created: 9/12/2026
Status: ✅ Merged
Merged: 9/12/2026
Merged by: @undefined
Base:
staging← Head:fix/6087-automatic-backup-free-space📝 Commits (5)
dfa7307fix(backup): check free space before writing the automatic backup244871cMerge remote-tracking branch 'origin/staging' into fix/6087-automatic-backup-free-space6547cc3fix(backup): log a failed free-space read before the automatic backupda6cbedtest: exercise automatic backup disk-space refusal and recovery3acccc2Merge branch 'staging' into fix/6087-automatic-backup-free-space📊 Changes
6 files changed (+174 additions, -2 deletions)
View changed files
📝
CHANGELOG.md(+2 -0)📝
docs/data/backup-and-restore.md(+4 -0)📝
packages/server/src/routes/backup.routes.ts(+37 -2)📝
packages/server/src/services/backup/automatic-backup-retention.ts(+13 -0)➕
scripts/regressions/automatic-backup-free-space.regression.ts(+98 -0)📝
scripts/regressions/automatic-backup-retention.regression.ts(+20 -0)📄 Description
Linked issue
Closes #6087
Why this change
backups/, on the same disk as the livestorage/tables, without checking that the space exists. The previous archive is kept until the new one is complete, so peak usage is two full archives plus the retained history.lastBackupAtis not advanced, so the backup stays due and the hourly timer retries the whole write, filling the disk again every hour while any other write on that disk can fail.What changed
automaticBackupFreeSpaceError(freeBytes, archiveBytes)inautomatic-backup-retention.ts: pure decision plus the message shown in Settings, with a fixed 256 MiB headroom on top of the archive size.writeFullBackupArchivetakes an optionalbeforeWrite(archiveBytes)hook, called after every source is collected and before the output file is opened. The archive is stored, not compressed, so the sum of the collected file sizes is the archive size apart from headers. Download Backup does not pass the hook and is unchanged.writeAutomaticBackuppasses the hook:fs.promises.statfsonbackups/, compare, throw the message if it does not fit. The existing catch stores it aslastError, which the Automatic Backups control already displays. Ifstatfsitself fails, the check is skipped and the backup proceeds as today, so the guard can never block a backup on its own.statfsbefore writing.docs/data/backup-and-restore.md; CHANGELOG entry under[Unreleased].Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
pnpm check: passed (exit code 0).node scripts/run-regressions.mjs --filter automatic-backup-retention: passed, including the new cases.fs.promises.statfschecked on Windows 10 against the data drive: it reports the same free space as the OS (253.5 GiB), so the guard works on Windows as well as Linux/Termux.DATA_DIR,TEMP,MARINARA_ENV_FILEpointing to a scratch folder, port 9123): enabling Automatic Backups (daily, keep 2) producedmarinara-automatic-backup.zip(29.2 MiB) within a second, withlastBackupAtset andlastError: null, so the happy path is unchanged when space is plentiful.Docs and release impact
docs-i18nbranch updated to match, or a[docs-i18n]follow-up issue opened (see CONTRIBUTING.md § Translated documentation)UI evidence (if applicable)
Not applicable: no UI change. The message reuses the existing
lastErrorslot next to the Automatic Backups control.Summary by CodeRabbit
New Features
Documentation
Tests
Maintainer sweep validation
Added
automatic-backup-free-space.regression.tsand ran it against an isolated real Fastify backup route: zero available space reports the error without changing the previous archive or leaving a partial ZIP; available space then permits a complete, readable ZIP and normal retention. The check mocks the free-space query rather than filling the host disk. Translated documentation is covered by #6097.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.