Skip to content

fix(launchbox): import local media when matching via update_rom#3687

Merged
gantoine merged 1 commit into
masterfrom
posthog-code/launchbox-update-media-import
Jul 5, 2026
Merged

fix(launchbox): import local media when matching via update_rom#3687
gantoine merged 1 commit into
masterfrom
posthog-code/launchbox-update-media-import

Conversation

@gantoine

@gantoine gantoine commented Jul 5, 2026

Copy link
Copy Markdown
Member

Description
Explain the changes or enhancements you are proposing with this pull request.

Manually (re)matching a LaunchBox ID through the ROM edit dialog ("Update metadata") never imported any LaunchBox media (e.g. local videos), even with video in scan.media. Unlike the ScreenScraper block in the same handler, the LaunchBox branch of update_rom:

  • fetched metadata via get_rom_by_id without fs_name/platform_slug, so local-media merging never ran;
  • never called populate_rom_specific_paths, so no {type}_path (e.g. video_path) was generated;
  • had no store_media_file loop, so nothing was ever copied into the resource store.

This PR fixes the LaunchBox branch of update_rom to:

  1. Pass fs_name/platform_slug to get_rom_by_id so local LaunchBox media resolves.
  2. Call populate_rom_specific_paths on the fetched metadata to generate media paths.
  3. Add a store_media_file loop mirroring the ScreenScraper/scan blocks, which also clears stale media when the LaunchBox ID changes.

Note: the scan/rescan path already imports LaunchBox video correctly (populate_rom_specific_paths is called in scan_handler.py with a persisted ROM, and the scan socket store loop copies it). The gallery-art (non-video images) question raised in the issue is intentionally out of scope here, as it needs a product/UI decision plus a new frontend surface.

AI assistance disclosure: This change was written with AI assistance (PostHog Code / Claude). The investigation, code changes, and tests were AI-generated and reviewed before submission.

Fixes #3521

Checklist
Please check all that apply.

  • I've tested the changes locally
  • I've updated relevant comments
  • I've assigned reviewers for this PR
  • I've added unit tests that cover the changes

Screenshots (if applicable)

N/A (backend-only change)


Created with PostHog Code

Manually (re)matching a LaunchBox ID through the ROM edit dialog never
imported any LaunchBox media. The update_rom endpoint fetched metadata
without fs_name/platform_slug (so local media never resolved), never
generated media paths, and had no store loop, unlike the ScreenScraper
block in the same handler.

Pass fs_name/platform_slug to get_rom_by_id, call
populate_rom_specific_paths on the fetched metadata, and add a
store_media_file loop that also clears stale media when the ID changes.

Fixes #3521

Generated-By: PostHog Code
Task-Id: 45791732-58e8-41c9-b616-4a91018e388d
Copilot AI review requested due to automatic review settings July 5, 2026 21:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a gap in the update_rom flow where manually setting/changing a LaunchBox ID (“Update metadata” from the ROM edit dialog) would fetch LaunchBox metadata but never resolve/copy local LaunchBox media (notably videos) into RomM’s resource store.

Changes:

  • Pass fs_name and platform_slug to LaunchBoxHandler.get_rom_by_id so local LaunchBox media can resolve during manual (re)match.
  • Run populate_rom_specific_paths for LaunchBox metadata during update_rom to generate {type}_path entries (e.g. video_path).
  • Add a LaunchBox store_media_file loop (including stale-media cleanup on ID change) mirroring the existing ScreenScraper logic, and add an endpoint test covering local video import.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
backend/endpoints/roms/init.py Ensures LaunchBox manual rematch resolves local media paths and copies media into the resource store (with cleanup when LaunchBox ID changes).
backend/tests/endpoints/roms/test_rom.py Adds a regression test asserting LaunchBox local video is assigned a video_path and copied via store_media_file during update_rom.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@gantoine gantoine merged commit d24d883 into master Jul 5, 2026
11 checks passed
@gantoine gantoine deleted the posthog-code/launchbox-update-media-import branch July 5, 2026 21:58
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.

LaunchBox local import: video files (and gallery art) never imported despite video in scan.media

2 participants