Skip to content

fix(ui): guard against empty Files slice in buildDownloads#225

Open
SAY-5 wants to merge 1 commit into
rommapp:mainfrom
SAY-5:fix/build-downloads-empty-files-223
Open

fix(ui): guard against empty Files slice in buildDownloads#225
SAY-5 wants to merge 1 commit into
rommapp:mainfrom
SAY-5:fix/build-downloads-empty-files-223

Conversation

@SAY-5
Copy link
Copy Markdown

@SAY-5 SAY-5 commented May 5, 2026

Fixes #223.

When the local cache holds a ROM row with has_multiple_files=false and an empty files array (observed after incremental cache updates), buildDownloads indexed g.Files[0] and panicked with index out of range [0] with length 0.

Skip the entry and log a warning instead. The download manager already tolerates an empty download list, and the user can refresh the library to repopulate file metadata.

Includes a regression test that exercises the empty-Files path and a sanity test for the single-file happy path.

Skip ROMs whose cached row has has_multiple_files=false and an empty
Files slice (and log a warning) instead of indexing g.Files[0]. This
panic was reachable when an incremental cache update wrote a row
without a files array.

Fixes rommapp#223

Signed-off-by: SAY-5 <say.apm35@gmail.com>
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.

Panic in buildDownloads when Files slice is empty (index out of range [0])

1 participant