Repository navigation
fix: restore the newest loadable backup instead of the oldest - #1654
Open
SameDesu123 wants to merge 1 commit into
Open
SameDesu123 wants to merge 1 commit into
SameDesu123 wants to merge 1 commit into
Conversation
When the save file fails to decode on the web/local and account sync paths, the restore loop kept going after a successful load, so every readable backup was loaded in turn and the oldest one won. Stop at the first (newest) backup that decodes, matching the Tauri path.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Checklist
Summary
When
database/database.binfails to decode on startup, the web/Node restore path loads the oldest readable backup instead of the newest one. Stop at the first backup that loads, as the Tauri path already does.Related Issues
None
Changes
src/ts/bootstrap.ts, the forage (web/Node) restore loop goes throughgetDbBackups(), which returns backups newest first. On each success it callssetDatabase(), setsbackupLoaded = true, and keeps going, so every readable backup is loaded in turn and the last one, the oldest, ends up as the live database. Add abreakafter a successful load.breakthere. In practice it rarely runs becausegetDbBackups()returns[]withuseSyncon the web.if (!backupLoaded)and is unchanged.History
getDbBackups()did not sort its keys.if (!backupLoaded)guard to the Tauri loop only. It also added the newest-first sort to foragegetDbBackups(). From then on, the unguarded forage loop deterministically ended on the oldest readable backup.bootstrap.tsunchanged.Impact
database.binalong with a new backup of the same old data. After about 20 saves, pruning has removed every backup that held the newer data, so the newer data cannot be recovered.database.bindecodes normally, and on Tauri.Additional Notes
pnpm check: 0 errorsREMOTEblock, so a damaged newest backup can still "load".database.binis missing entirely, a new empty save is created without trying the backups.getDbBackups()prunes to 20 even when it is called from the restore path.Footnotes
Modifies the behavior of prompting, requesting, or handling responses from AI models. ↩
Over 80% of the code is AI generated. ↩