Fix gamelist.xml export to use relative media paths for local exports#3369
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR updates gamelist XML export to emit media paths as ROM-relative paths when local_export=True, allowing exported gamelists to be portable alongside ROM folders.
Changes:
- Added a helper to compute resource paths relative to the ROM’s directory for local exports.
- Updated all media tag generation (
thumbnail,image,video,screenshot,manual, and provider-specific tags) to use the helper. - Expanded unit tests to ensure local exports don’t emit absolute media paths.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| backend/utils/gamelist_exporter.py | Centralizes media path building and switches local exports to ROM-relative resource paths. |
| backend/tests/utils/test_gamelist_exporter.py | Adds/updates fixtures and tests to validate relative paths for local exports. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Use URLPath.make_absolute_url with request.base_url to build resource URLs for non-local exports, and simplify the local-export traversal check with Path.is_relative_to. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Mirror the pegasus exporter pattern: collect each ROM's media into a canonical asset-kind dict, then either copy the files under <platform>/assets/<subdir>/ for local exports or build absolute URLs from request.base_url for remote exports. Exclude the generated assets/ directory from filesystem scans. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Cover the local-export flow end to end: redirect resource and library base paths into a tmp_path sandbox, run export_platform_to_file, and assert that media files land at <platform>/assets/<subdir>/<rom>.<ext> and that gamelist.xml references them. A second test withholds source files to verify that failed copies omit their tags from the XML while other assets still export. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR changes local exports to use paths relative to the ROM's filesystem location, making the references meaningful and portable.
When exporting
gamelist.xmlwithscan.export_gamelistenabled, all media paths (thumbnails, images, videos, screenshots, manuals, and provider-specific assets like box3d, fanart, etc.) were written as absolute paths prefixed with/assets/romm/resources/.... This made the exportedgamelistunusable outside of RomM's web frontend.This PR partially addresses #3287, though notably ES-DE does not actually use the image/media related fields in the gamelist (see Discord comments). That said, relative paths enable further automation (e.g., symlinking resources to locations ES-DE expects) which was previously impossible with hardcoded absolute web paths. Deeper ES-DE integration is outside the scope of this PR.
Checklist
Please check all that apply.
AI Usage
Claude code was used in assisting these changes, though I was the primary driver and have closely reviewed all of the code.