Skip to content

Recover from corrupted repos.json - #33

Open
timkicker wants to merge 2 commits into
fortheusers:mainfrom
timkicker:fix/repos-json-resilience
Open

timkicker wants to merge 2 commits into
fortheusers:mainfrom
timkicker:fix/repos-json-resilience

Conversation

@timkicker

@timkicker timkicker commented May 3, 2026 •

Copy link
Copy Markdown

Fixes fortheusers/hb-appstore#163. A repos.json full of NUL bytes left libget without any repos for good. Now it gets kept as repos.json.bad and the default is written again. saveRepos writes the file directly and syncs it, without a tmp file or rename.

@compucat

Copy link
Copy Markdown
Member

Thanks! Looks good on quick readthrough. I'm cool to merge this as part of other HBAS updates; we can check for platform compatibility bugs as part of on-device testing for next HBAS release and backport changes if necessary.

@vgmoose your call.

@compucat compucat mentioned this pull request Jun 15, 2026
@vgmoose

vgmoose commented Jun 16, 2026

Copy link
Copy Markdown
Member

I'm actually a little cagey on this just because of how file streams and rename operations work (or, don't work) on homebrew platforms. Can we accomplish something similar without a tmp file first?

@timkicker
timkicker force-pushed the fix/repos-json-resilience branch from efc11cb to 9b6ae07 Compare November 18, 2026 10:18
@timkicker timkicker changed the title get: harden repos.json save/load against empty/corrupted state Recover from corrupted repos.json Nov 18, 2026
@timkicker

Copy link
Copy Markdown
Author

I finally had a chance to look more into this. The rename was a real problem because libfat and libnx don't replace an existing file, so every save after the first would fail. I took the tmp file out and saveRepos writes repos.json directly again.

What actually breaks in #163 is a repos.json full of NUL bytes (what FAT tends to leave after a power cut). main stays stuck with zero repos there. The load side now moves it to .bad and writes the default. Added a test for that.

@timkicker timkicker mentioned this pull request Nov 19, 2026

This branch has not been deployed

No deployments
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.

(WIIU) hb app store keeps emptying ./get/repos.json

3 participants