mirror of
https://github.com/rommapp/romm.git
synced 2026-06-28 06:46:00 +00:00
Replace the `_link_rom_files_to_parent` post-fetch hook with the declarative loader pattern PR #3425 originally removed, restoring `joinedload(RomFile.rom).load_only(Rom.fs_path, Rom.fs_name)` on the two queries that still load `Rom.files` (`with_details` and `get_roms_by_fs_name`). #3425 dropped that joinedload everywhere as part of denormalizing file stats into the `multi_file` / `top_level_file_count` column properties. But `is_top_level` / `file_name_for_download` (multi-file downloads, 3DS QR codes, metadata matching) still read `RomFile.rom.full_path`, so the two file-loading paths were over-cleaned, causing a `DetachedInstanceError` (500) on multi-file downloads once the session closed. The gallery query (`filter_roms`) dropped `Rom.files` entirely and is untouched, so the performance win from #3425 is preserved; the restored join only adds an index-backed PK lookup of two columns to the existing files `selectin` on the detail/scan paths. https://claude.ai/code/session_01PSXKmejPRzdxLFMN6P2QQ4