Skip to content
This repository was archived by the owner on Jan 9, 2026. It is now read-only.

Handles relative image URLs and ensures dir exists#74

Merged
gantoine merged 3 commits intorommapp:mainfrom
ZacharyKeatings:boxart
Jan 9, 2026
Merged

Handles relative image URLs and ensures dir exists#74
gantoine merged 3 commits intorommapp:mainfrom
ZacharyKeatings:boxart

Conversation

@ZacharyKeatings
Copy link
Contributor

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

This PR addresses two issues that could cause failures when downloading and processing ROM assets:

  1. Relative URL handling: The load_image_from_url method in ImageUtils now automatically prepends the host URL (from the HOST environment variable) to relative image URLs. Previously, relative URLs like /api/images/cover.png would fail to load because they lacked a full domain. Now, if a URL doesn't start with http:// or https://, the host is automatically prepended, ensuring images load correctly regardless of whether the API returns absolute or relative URLs.

  2. Directory creation: Added os.makedirs(catalogue_path, exist_ok=True) in the download_rom method to ensure the catalogue directory exists before attempting to write ROM metadata and assets. This prevents FileNotFoundError exceptions when the catalogue directory structure hasn't been initialized yet.

Changes Made

  • Modified RomM/imageutils.py: Added logic to detect and prepend host URL to relative image URLs in load_image_from_url method
  • Modified RomM/api.py: Added directory creation for catalogue path before writing ROM metadata and assets

Testing

  • Tested with both relative and absolute image URLs
  • Verified that catalogue directories are created automatically when needed
  • Confirmed that existing absolute URLs continue to work without modification

Checklist
Please check all that apply.

  • I've tested the changes locally
  • I've updated relevant comments
  • I've assigned reviewers for this PR

Screenshots

Ensures that relative image URLs are correctly handled by prepending the host URL. This prevents broken image links when the URL is relative.

Creates the destination directory for catalogue entries if it does not already exist.
@gemini-code-assist
Copy link

Summary of Changes

Hello @ZacharyKeatings, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the robustness of ROM asset downloading by addressing two common failure points. It introduces logic to correctly resolve relative image URLs by prepending the configured host, ensuring images are always fetched from a complete URL. Additionally, it guarantees that target directories for ROM metadata and assets are created automatically if they don't already exist, preventing file system errors during the download process.

Highlights

  • Relative Image URL Handling: The load_image_from_url method in ImageUtils now automatically prepends the host URL (from the HOST environment variable) to relative image URLs. This ensures that images load correctly whether the API returns absolute or relative paths.
  • Catalogue Directory Creation: The download_rom method now includes os.makedirs(catalogue_path, exist_ok=True) to ensure the catalogue directory exists before attempting to write ROM metadata and assets, preventing FileNotFoundError exceptions.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces two improvements: handling relative image URLs and ensuring the existence of catalogue directories. The change to handle relative URLs in imageutils.py is a good idea, but the implementation could be made more robust by using urllib.parse.urljoin to correctly handle all types of relative URLs. The change in api.py to create the catalogue directory is helpful, but it appears to be redundant as other parts of the code already ensure the necessary directories are created. My review includes suggestions to address these points for improved robustness and code clarity.

@gantoine gantoine merged commit 294ba6f into rommapp:main Jan 9, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants