mirror of
https://github.com/rommapp/romm.git
synced 2026-06-28 06:46:00 +00:00
The scan loaders no longer eager-load `Rom.files` (#3425 + follow-ups), so the hash-based metadata lookups can't rely on `rom.files` being populated — `hasheous`/`ss` `lookup_rom` read `RomFile.is_top_level`, which dereferences `RomFile.rom.full_path` and would raise `DetachedInstanceError` once the session closed. Add `DBRomsHandler.rom_files_for_rom_id`, which loads a ROM's files on demand with the `RomFile.rom` backref eager-loaded (`load_only(fs_path, fs_name)`). The scan path uses it as a fallback only when the filesystem walk yielded no files (e.g. an unchanged rescan), behind a per-ROM `functools.cache` helper so the playmatch/hasheous/ss lookups share a single DB fetch. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>