Skip to content

fix(downloads)!: preserve file extension for nested single-file ROMs#263

Merged
danielcopper merged 1 commit intomainfrom
fix/226-nested-single-file-extension
May 4, 2026
Merged

fix(downloads)!: preserve file extension for nested single-file ROMs#263
danielcopper merged 1 commit intomainfrom
fix/226-nested-single-file-extension

Conversation

@danielcopper
Copy link
Copy Markdown
Owner

Summary

Fixes #226. When a ROM is stored as a single file inside a per-game folder in RomM (e.g. Resident Evil/Resident Evil.chd), the API sets has_nested_single_file=true and fs_name is the folder name without extension. The plugin used fs_name as the local target filename, so downloads were stored without the file extension and could not be launched.

What changed

  • _resolve_local_file_name helper picks the correct on-disk filename based on RomM's file-layout flags. When has_nested_single_file=true, derive the filename from files[0].file_name (which carries the extension); otherwise keep using fs_name.
  • Defensive fallback: if files is empty or missing on a nested-single-file ROM (shouldn't happen per RomM's API contract), fall back to fs_name and log a warning.
  • Resolved once in start_download and threaded through _do_download as a parameter — no double resolution, no duplicate warning logs.
  • Wiki: documented the three RomM file-layout flags and the plugin's local-layout decision in Backend-Architecture.md (separate wiki commit).

Layout decision

Nested-single-file ROMs are placed flat in the platform folder (e.g. dc/Resident Evil.chd), not mirroring the RomM folder structure. By definition has_nested_single_file means exactly one file in that folder — any sidecar files would flip RomM to has_multiple_files. Flat layout matches has_simple_single_file behavior; multi-file ROMs still keep their per-game subfolder.

Breaking change

Existing local installs of nested-single-file ROMs are stored without their file extension. After this release, affected ROMs need to be re-downloaded (or re-synced) so the on-disk filename is corrected — buggy entries cannot be patched in place. release-please will surface this in the changelog.

Test plan

  • pytest tests/ -q — 1732 passed (7 new)
  • ruff check py_modules tests main.py — clean
  • basedpyright py_modules tests main.py — 0 errors / 0 warnings / 0 notes
  • Branch coverage on _resolve_local_file_name — 100% (line + branch)
  • Original reporter retest after release (asked on issue)

…226)

When a ROM is stored as a single file inside a per-game folder in RomM
(e.g. `Resident Evil/Resident Evil.chd`), the API sets
`has_nested_single_file=true` and `fs_name` is the folder name without
extension. The plugin used `fs_name` as the local target filename, so
the downloaded ROM was stored without its extension and could not be
launched.

Resolve the on-disk filename from `files[0].file_name` when
`has_nested_single_file=true`, falling back to `fs_name` with a
warning if `files` is empty or missing. Nested-single-file ROMs land
flat in the platform folder (no folder mirroring) — by definition
they have no sidecars, so the parent folder adds no value locally,
and flat layout matches `has_simple_single_file` behavior. Multi-file
ROMs are unaffected.

BREAKING CHANGE: Existing installs of nested single-file ROMs were
stored locally without their file extension. Affected ROMs must be
re-downloaded (or re-synced via the plugin) after updating so the
on-disk filename is corrected — buggy entries cannot be patched in
place.
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 4, 2026

@danielcopper danielcopper merged commit dbe14f4 into main May 4, 2026
9 checks passed
@danielcopper danielcopper deleted the fix/226-nested-single-file-extension branch May 4, 2026 15:16
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.

Single ROM file within a folder: file extension is lost upon download

1 participant