Skip to content

Refuse backups when a folder with recorded archives is missing - #791

Merged
Zaldaryon merged 3 commits into
devfrom
fix/issue-748-missing-backup-folder
Nov 11, 2026
Merged

Zaldaryon merged 3 commits into
devfrom
fix/issue-748-missing-backup-folder

Conversation

@Zaldaryon

@Zaldaryon Zaldaryon commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

A missing backup folder can be an unmounted drive. Recreating it while old archives are listed lets a later backup mistake those archives for deleted files. Refuse to recreate that folder while any installation has records pointing into it. This covers both the shared Worlds folder and installations whose names produce the same backup folder. A first backup into a new folder still works. Play offers to continue without a backup after the refusal.

Type

  • Bug fix

Testing

Covered repeated installation backups, two installations with the same backup folder, worlds in different installations and the Play prompt. Local typecheck, lint, formatting, coverage and unpacked build passed. Coverage: 305 files, 5,973 tests passed, 4 skipped.

Related issues

Fixes #748

When an installation or world backups folder was missing (for example on
an unmounted drive or moved directory) while its parent path remained
writable, creating a new backup recreated the output folder to write the
new archive. The subsequent prune checked archive state on the now-existing
folder, saw the file missing and the parent folder present, and classified
the older archive as gone rather than unreachable, dropping its record.

Capture archive states before compression creates the output directory in
both makeInstallationBackup and makeWorldBackup, and pass them to
pruneOldestBackups so that recreated folders do not drop older records.

Fixes #748
@Zaldaryon
Zaldaryon marked this pull request as ready for review October 27, 2026 14:09
@Zaldaryon
Zaldaryon requested a review from Pixnop October 27, 2026 14:09

@Pixnop Pixnop left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed e8c709a7 against dev adab6b96: ran your new tests against dev's code, then backed up twice in a row, and two worlds in a row, with the Backups folder missing.

This PR does what I suggested in #748, and that suggestion was wrong. The states taken before the compression only last for the prune of that one backup. The folder the compression creates is still there afterwards, so the next backup can no longer tell a missing drive from deleted archives. Sorry for sending you down that road. Two things have to change before this goes in.

Blocking

The next backup still drops the old records

initialStates is computed once per call (backup.ts:270) and only reaches that call's prune (backup.ts:283). The compression worker creates the output folder (compression.ts:168), and the folder stays. On the next backup, archiveState (backup.ts:117-125) finds the archive missing and its folder present, says "gone", and the record comes off.

Scenario: the drive holding the Backups folder is not mounted, so its mount point is an empty folder. Backup 1 recreates Backups/Installations/<name> there, and the old rows survive thanks to this PR. Backup 2 drops them. It can come soon: with automatic backups on, Play makes one first (useLaunchGame.ts:130-131). A test that makes two backups through makeInstallationBackup, with a fake archiver that creates the output folder and a limit of 3, gets [] for the first deletedBackupIds and ["old"] for the second.

World backups lose other worlds' records on their very first backup

Every world backup of every Installation goes into one folder, join(config.backupsFolder, "Worlds") (worldsHandlers.ts:226), but initialStates only covers the world being backed up (worldsHandlers.ts:230). With that folder missing, a backup of world A recreates it. The first backup of world B then reads B's old archives as gone and drops them. The same goes for the worlds of another Installation. I added that case to worldsHandlers.test.ts: two worlds, an old backup of B in the missing Worlds folder, a backup of A then of B. rb.deletedBackupIds comes back with B's old record in it.

A direction

Once the folder has been recreated, nothing on disk tells the two cases apart, so the state can't be carried inside one call. I think the fix is to not recreate it while the config still points into it. Before compressing, if the output folder is missing and a listed backup has its archive in that folder (for worlds: any world backup in Worlds, from any Installation), refuse the backup with a reason the renderer can show, something like "This Installation's Backups folder is missing. Put it back or mount the drive, or delete the backups listed from it." That also keeps archives from landing on the wrong drive under an empty mount point.

A few things to keep in mind:

  • The check has to be on the records, not on the Backups root alone. The default RiftLauncherBackups folder is never created up front, so a first backup into a folder that does not exist yet is normal and must still work.
  • Deleting a row whose archive is missing already works (backupDeletion.ts:39-43), so the player always has a way out.
  • With automatic backups on, Play treats any refusal other than compress-failed as a hard stop (useLaunchGame.ts:137-139). The new reason should get the "launch without a backup" question, or a missing drive blocks Play.
  • archiveStates can then go away, and #610 keeps working as it does on dev: an archive deleted from a folder that is still there is still dropped.

Tests

Two of the three new tests pass on dev's code, so they don't hold the fix:

  • tests/domain/installations/backup.test.ts, "keeps older backups whose folder went missing when compression recreates the folder (#748)": the fake still reports the folder as absent after the compression. For any path under /backups/Installations/, exists returns present.has(path) (line 34), and present is empty, so the folder never comes back.
  • tests/renderer-dom/useMakeInstallationBackup.test.tsx, "keeps older backups whose folder was missing before the backup": once folderRecreated is set, checkPathExists returns true for every path under /parent/drive/Backups (line 270), the old archive included. The old archive reads as on disk again, which is the drive coming back rather than an empty folder being recreated.

The world test in worldsHandlers.test.ts does fail on dev, so that one is a real catch. Whatever the fix ends up being, the two-backup and two-world cases above are the tests I'd want next to it.

Not blocking

  1. If archiveStates stays, one shape would do. The array form depends on the caller passing the same backups array in the same order, and a ReadonlyMap keyed by id covers both callers. In worldsHandlers.ts the inline exists and the copied record repeat the fileSystem object and mapping built a few lines below.

@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Translation status

en-US is the source and carries 962 keys.

Locale Keys Missing Stale To review on Weblate
be-BY 882 117 0 Needs editing
de-DE 855 107 0 Needs editing
es-ES 882 117 0 Needs editing
fr-FR 999 0 0 Needs editing
hu-HU 855 107 0 Needs editing
it-IT 882 117 0 Needs editing
nl-NL 855 107 0 Needs editing
pl-PL 882 117 0 Needs editing
pt-BR 883 116 0 Needs editing
pt-PT 882 117 0 Needs editing
ru-RU 996 5 2 Needs editing
uk-UA 882 117 0 Needs editing
zh-CN 828 97 0 Needs editing

The links open the strings Weblate marks Needs editing for each language: the machine drafts made before Weblate, plus any string whose English changed since it was translated. See #496.

@Zaldaryon Zaldaryon changed the title Preserve unreachable backups when a missing folder is recreated (#748) Refuse backups when a folder with recorded archives is missing Nov 10, 2026
@Zaldaryon

Copy link
Copy Markdown
Collaborator Author

595f3477 removes the archive state snapshot and refuses compression while the missing output folder still has recorded archives. The shared Worlds folder check reads records from all installations. Play offers to continue without a backup after the refusal.

Regression tests cover two backup attempts, two worlds in different installations, and the Play prompt. Typecheck, lint, formatting, unpacked build and coverage passed locally (5,915 passed, 4 skipped). CI is running on this commit.

@Zaldaryon
Zaldaryon requested a review from Pixnop November 10, 2026 22:48

@Pixnop Pixnop left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed 595f3477 against e8c709a7: read the whole PR again, ran the four new tests against dev's code, took each fix back out one at a time to see which test goes red, and backed up two Installations that share a backup folder with a fake that creates the folder on compression.

Round one

The second backup no longer drops the old rows. The check at backup.ts:263 refuses before a name is picked or anything is compressed, inside the try, so the lease, the close guard and _backuping are all released. backup.test.ts:394 and useMakeInstallationBackup.test.tsx:249 fail on dev and fail again when I remove that line.

World backups no longer lose other records. worldsHandlers.ts:228-236 checks the world backups of every Installation. worldsHandlers.test.ts:773 fails on dev, and fails when I narrow the check to the Installation being backed up.

A first backup into a folder that does not exist yet still works. The check is on the records, and the existing archiving and first world backup tests pass.

Play offers to launch without a backup. useLaunchGame.ts:138, held by launchPlayGame.test.tsx:569 (see note 2).

archiveStates is gone and #610 behaves as on dev. The test at backup.test.ts:292 passes. My optional note on its shape is moot.

Approving. Thanks for taking the new direction this cleanly.

Not blocking

  1. Two Installations that share a backup folder can still lose rows. The folder is Installations/<cleanFolderName(name)>, and names are not unique ("Survival" twice, or "Survival 1" and "Survival:1"). With the drive gone, an Installation with no rows in that folder passes the check and recreates it, and the other one's next backup drops its rows. I reproduced it with the real makeInstallationBackup: deletedBackupIds came back as ["old-a"]. Passing every Installation's backups to isRecordedBackupFolderUnavailable, as the world handler does, closes it, with a test of two snapshots sharing a name.
  2. The Play test passes on dev. checkPathExists at launchPlayGame.test.tsx:584 answers true for every candidate archive, so without the refusal the backup fails as compress-failed ("No free archive name") and the same prompt shows. Answering false for anything under outputFolder would make it hold the refusal too.
  3. The world refusal can point at rows this page does not list. ManageInstallationWorlds.tsx:85 reuses the installation message, but the refusal can come from another Installation's world backups, as in your own test. A features.worlds.error.backup-folder-unavailable key that mentions every Installation's Worlds page would also drop that special case.
  4. The new string reads differently from its neighbours. They all open with "No backup made:", and the ones that name the folder say "Backups folder". Something like "No backup made: the folder this Installation's backups are in is missing. Reconnect the drive or put the folder back, or delete the backups listed from it." with fr-FR to match.

docs/contribute/translation-status.md conflicts with #797 and #803. #793 merges cleanly but leaves the table stale. Whichever lands second needs to regenerate it.

@Zaldaryon
Zaldaryon merged commit 7a0c001 into dev Nov 11, 2026
21 of 23 checks passed
@Zaldaryon
Zaldaryon deleted the fix/issue-748-missing-backup-folder branch November 11, 2026 01:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants