Skip to content

fix: write RFL_DB.dat and rksys.dat atomically - #310

Open
patchzyy wants to merge 1 commit into
devfrom
fix/atomic-save-writes
Open

fix: write RFL_DB.dat and rksys.dat atomically#310
patchzyy wants to merge 1 commit into
devfrom
fix/atomic-save-writes

Conversation

@patchzyy

@patchzyy patchzyy commented Aug 7, 2026

Copy link
Copy Markdown
Member

Purpose

RFL_DB.dat and rksys.dat were rewritten in place on every Mii edit / license change, so a crash or full disk mid-write left a truncated file and lost all Miis or all four licenses.

What Changed

New IFileSystem.WriteAllBytesAtomic helper writes to a .tmp, flushes it, then swaps it in with File.Replace keeping a .bak (plain move when the file is new). MiiRepositoryService and SaveRksysToFile now use it, and rksys.dat is no longer written at all when the buffer is not exactly RksysSize.

How to Test

Edit/rename a Mii and rename a license; both save correctly and leave a .bak next to the file, no .tmp leftovers. dotnet test passes (177 tests, 3 new).

Both save files were rewritten in place, so an interrupted write left a
truncated file and lost all Miis or all licenses. Writes now go through a
temp file that is flushed and swapped in with File.Replace, keeping a .bak.
Also refuse to save rksys.dat when the buffer is not exactly RksysSize.
@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: e6e22ddb-dea7-4eed-a9b6-ae8655c9e5cd

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

1 participant