Skip to content

Fix gamelist.xml export to use relative media paths for local exports#3369

Merged
gantoine merged 8 commits into
rommapp:masterfrom
gtronset:gt-relative-gamelist-assets
May 16, 2026
Merged

Fix gamelist.xml export to use relative media paths for local exports#3369
gantoine merged 8 commits into
rommapp:masterfrom
gtronset:gt-relative-gamelist-assets

Conversation

@gtronset
Copy link
Copy Markdown
Contributor

@gtronset gtronset commented May 13, 2026

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.xml with scan.export_gamelist enabled, 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 exported gamelist unusable 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.

  • 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

AI Usage

Claude code was used in assisting these changes, though I was the primary driver and have closely reviewed all of the code.

Copilot AI review requested due to automatic review settings May 13, 2026 22:08
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

Comment thread backend/utils/gamelist_exporter.py Outdated
Comment thread backend/utils/gamelist_exporter.py Outdated
Comment thread backend/tests/utils/test_gamelist_exporter.py
Comment thread backend/tests/utils/test_gamelist_exporter.py
gtronset and others added 3 commits May 13, 2026 15:23
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>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

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

Comment thread backend/utils/gamelist_exporter.py
Comment thread backend/utils/gamelist_exporter.py
gantoine and others added 2 commits May 16, 2026 08:54
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>
@gantoine gantoine merged commit 9eecb67 into rommapp:master May 16, 2026
5 checks passed
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.

3 participants