Commit 17e8b1a
authored
fix: decrypt local backup data before loading (#1488)
## PR Checklist
- Required Checks
- [x] Have you added type definitions?
- [x] Have you tested your changes?
- [x] Have you checked that it won't break any existing features?
- [ ] If your PR uses models[^1], check the following:
- [ ] Have you checked if it works normally in all models?
- [ ] Have you checked if it works normally in all web, local, and
node-hosted versions? If it doesn't, have you blocked it in those
versions?
- [x] If your PR is highly AI generated[^2], check the following:
- [x] Have you understood what the code does?
- [x] Have you cleaned up any unnecessary or redundant code?
- [x] Is it not a huge change?
- We currently do not accept highly AI generated PRs that are large
changes.
[^1]: Modifies the behavior of prompting, requesting, or handling
responses from AI models.
[^2]: Over 80% of the code is AI generated.
## Summary
Fixes encrypted local backup loading for account-synced web backups.
The encrypted backup path was fetching the stored crypto key correctly,
but then called `encryptBuffer` while handling `database.risudat`. That
re-encrypted the already encrypted database bytes instead of decrypting
them, causing `decodeRisuSave` to receive invalid data and eventually
fail with fflate errors such as `invalid distance`.
## Related Issues
None.
## Changes
**`src/ts/drive/backuplocal.ts`**
- Import `decryptBuffer`
- Use `decryptBuffer(db, key)` when loading an encrypted
`database.risudat`
- Keep the save path unchanged, where `encryptBuffer(dbData, key)` is
still used to create encrypted backups
## Impact
- Encrypted local backups created from account-synced `risuai.xyz` web
sessions can be loaded correctly.
- Non-encrypted local backups are unaffected because they do not enter
the `encryption.risudat` path.
- Partial local backups are unaffected because they are not encrypted by
this path.
- The save format does not change.
## Additional Notes
Validated with:
- `pnpm check`
- `pnpm test`
- `pnpm build`1 file changed
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| |||
504 | 504 | | |
505 | 505 | | |
506 | 506 | | |
507 | | - | |
| 507 | + | |
508 | 508 | | |
509 | 509 | | |
510 | 510 | | |
| |||
0 commit comments