mirror of
https://github.com/rommapp/romm.git
synced 2026-06-28 06:46:00 +00:00
Restore the "platform only" contract of `get_roms_by_fs_name` (per its docstring) by dropping the `selectinload(Rom.files)` + `joinedload`. That load only existed for `scan_rom`'s rare `fs_rom["files"] or rom.files` fallback, but it forced files (and a per-file join back to roms) for every ROM in a scan batch — expensive on large platforms, and only used when the filesystem scan yielded no files. Instead, fetch the persisted files on demand: `scan_rom` now resolves match files via a small helper that returns the filesystem-scanned files, falling back to `db_rom_handler.get_rom_files_by_rom_id(rom.id)` only when there are none. The new getter eager-loads the `RomFile.rom` backref so `is_top_level` keeps working on the detached results (the rare path was already latently broken on master, which loaded files without the backref). https://claude.ai/code/session_01PSXKmejPRzdxLFMN6P2QQ4