Skip to content

get: harden repos.json save/load against empty/corrupted state#33

Open
timkicker wants to merge 1 commit into
fortheusers:mainfrom
timkicker:fix/repos-json-resilience
Open

get: harden repos.json save/load against empty/corrupted state#33
timkicker wants to merge 1 commit 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.
saveRepos now writes via tmp + atomic rename with fsync and loadRepos regenerates the default for empty/corrupted files (with the bad file preserved as repos.json.bad).

  state

saveRepos writes via tmp + atomic rename with fsync, so a crash
  mid-write can't truncate the file. loadRepos regenerates the default when
  the parsed repos array is empty or the JSON is corrupted; on parse failure
  the bad file is moved to repos.json.bad instead of being overwritten.
  Drive-by: missing <cstdint> include in Utils.hpp.

Closes
  fortheusers/hb-appstore#163
@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?

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