Skip to content

[ROMM-3067] Always sub dash with colon for launchbox matching#3090

Merged
gantoine merged 1 commit intomasterfrom
romm-3067
Mar 8, 2026
Merged

[ROMM-3067] Always sub dash with colon for launchbox matching#3090
gantoine merged 1 commit intomasterfrom
romm-3067

Conversation

@gantoine
Copy link
Copy Markdown
Member

@gantoine gantoine commented Mar 8, 2026

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

Fixes #3067

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

@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Mar 8, 2026

Greptile Summary

This PR fixes a bug in the LaunchBox metadata handler where the dash-to-colon substitution (converting " - "/"- "": ") was only applied when keep_tags=False, meaning searches triggered via get_matched_roms_by_name (which passes keep_tags=True) would fail to match LaunchBox entries that use colons in their titles. The fix moves the re.sub call outside the if/else block so it applies unconditionally before the remote lookup.

  • Bug fix (core): re.sub(DASH_COLON_REGEX, ": ", search_term).lower() is now applied to search_term regardless of the keep_tags value, ensuring consistent title normalization for both scan-time and manual-search paths.
  • Cleanup: get_matched_roms_by_name now passes keep_tags=True as a keyword argument instead of a positional boolean for readability.
  • Cleanup: get_matched_rom_by_id removes the redundant explicit remote_enabled=True since it matches the default value of the parameter.

Confidence Score: 5/5

  • This PR is safe to merge — it applies a straightforward one-line reordering to fix a clear bug, with no side effects.
  • The change is minimal and surgical: the substitution was already correct in the keep_tags=False path, and moving it outside the conditional simply extends the same behavior to the keep_tags=True path without altering any other logic. The two cleanup changes (keyword arg and removing an explicit default) are functionally identical to what was there before.
  • No files require special attention.

Important Files Changed

Filename Overview
backend/handler/metadata/launchbox_handler/handler.py Moves the dash-to-colon substitution outside the keep_tags branch so it always applies, fixes keep_tags=True positional arg style, and removes redundant remote_enabled=True default arg. All changes are correct and safe.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["get_rom(fs_name, platform_slug, keep_tags)"] --> B{Local match found?}
    B -- Yes --> C[Return local + remote merged ROM]
    B -- No --> D{LaunchBox ID tag in filename?}
    D -- Yes --> E[get_rom_by_id]
    E --> F{ID found?}
    F -- Yes --> G[Return ROM by ID]
    F -- No --> H{remote_available?}
    D -- No --> H
    H -- No --> I[Return fallback_rom]
    H -- Yes --> J{keep_tags?}
    J -- "False" --> K["search_term = get_file_name_with_no_tags(fs_name)"]
    J -- "True" --> L["search_term = fs_name"]
    K --> M["re.sub(DASH_COLON_REGEX, ': ', search_term).lower()  ← applied in BOTH branches now"]
    L --> M
    M --> N{platform_slug == SCUMMVM?}
    N -- Yes --> O["_scummvm_format(search_term)"]
    N -- No --> P["_remote.get_rom(search_term, ...)"]
    O --> P
    P --> Q{index_entry found?}
    Q -- No --> R[Return fallback_rom]
    Q -- Yes --> S[Return remote ROM]
Loading

Last reviewed commit: 207f8a3

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

Improves LaunchBox metadata matching by normalizing ROM search terms so Windows-friendly - separators match LaunchBox’s : naming convention, including in manual name searches (keep_tags mode).

Changes:

  • Apply DASH_COLON_REGEX dash→colon normalization regardless of keep_tags, and lowercase in one step.
  • Make keep_tags=True usage explicit in get_matched_roms_by_name.
  • Simplify get_matched_rom_by_id to rely on get_rom_by_id’s default remote_enabled=True.

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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 8, 2026

Test Results (postgresql)

942 tests  ±0   941 ✅ ±0   2m 15s ⏱️ -1s
  1 suites ±0     1 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit 207f8a3. ± Comparison against base commit 9dd155a.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 8, 2026

Test Results (mariadb)

942 tests  ±0   941 ✅ ±0   2m 15s ⏱️ ±0s
  1 suites ±0     1 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit 207f8a3. ± Comparison against base commit 9dd155a.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 8, 2026

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
13805 9258 67% 0% 🟢

New Files

No new covered files...

Modified Files

File Coverage Status
backend/handler/metadata/launchbox_handler/handler.py 98% 🟢
TOTAL 98% 🟢

updated for commit: 207f8a3 by action🐍

@gantoine gantoine merged commit 64f2360 into master Mar 8, 2026
15 checks passed
@gantoine gantoine deleted the romm-3067 branch March 8, 2026 22:44
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.

[Feature] Improvements to LaunchBox Metadata Search

2 participants