Commit Graph

4396 Commits

Author SHA1 Message Date
Sam Dornan
26f595d8b9 fix(hltb): match titles whose series prefix the catalogue omits
HowLongToBeat is searched with the filename, and a series prefix that one
side carries and the other does not sinks a strict similarity gate: "007:
Quantum of Solace" scores 0.838 against the catalogue's "Quantum of
Solace", just under 0.85, and a term long enough returns no results at
all. Every James Bond title on PlayStation 2 missed for one of those two
reasons.

Retry with the part after the last separator, the same recovery Moby and
ScreenScraper already make. The trigger is broader than theirs, which
only retry an empty result set: a scored-but-rejected result has to
retry too, since that is how "Quantum of Solace" fails.

Verified against the live API: all five PlayStation 2 James Bond titles
now resolve, and six subtitle-heavy titles that could plausibly match the
wrong game on a tail-only search are unaffected, because the full term
matches first.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-17 17:01:28 -05:00
Georges-Antoine Assi
7f5764660d Merge pull request #4219 from sdornan/claude/libretro-thumbnails-404-108626
fix(libretro): cache missing thumbnail listings
2026-08-17 08:56:16 -04:00
Georges-Antoine Assi
f30a58228e Merge pull request #4218 from sdornan/fix/rescan-reparse-filename-tags
fix(scan): re-read filename tags on a complete rescan
2026-08-17 08:45:01 -04:00
Georges-Antoine Assi
f3e3dc09d4 refactor(config): move public base URL helpers to utils.urls
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-17 08:10:50 -04:00
Sam Dornan
7a104994d9 fix(libretro): only cache misses for absent directories
Caching every 4xx meant a transient 429, 408, or 403 on an existing
directory would suppress that platform's artwork for an hour. Restrict
the negative cache to 404 and 410, which mean the directory is absent.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-16 23:27:30 -05:00
Sam Dornan
deae84a298 fix(libretro): cache missing thumbnail listings
Failed listing requests returned early without writing to Redis, so a
platform with no directory for an art type re-requested it once per ROM.
Scanning a 3DS library logged a 404 for Named_Logos on nearly every ROM.

Cache the empty result on a 4xx with a shorter TTL, since a missing
directory is stable but could be added upstream later. Server and
connection errors stay uncached because they are transient.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-16 23:23:35 -05:00
Sam Dornan
f22aadf77a fix(scan): re-read filename tags on a complete rescan
A rom parsed its filename tags when it was first inserted and never again,
so a change to parse_tags only reached rows scanned after it. The freshly
parsed values were built for every rom but only consumed on the insert
path, and scan_rom reseeded the tag columns from the existing row, so no
scan type could refresh them.

A complete rescan (or an explicit per-rom selection) now writes them back.
A hashes rescan still doesn't, since it is scoped to re-reading file bytes.

scan_rom also carries "version" forward now. It was the one tag column
missing from its attrs, so a re-parsed version would have been dropped, as
the value written by the reassociation path already was.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-16 21:38:12 -05:00
Sam Dornan
ed65d6f5f4 fix(auth): reject all loopback hosts in public base URL
Classify the ROMM_BASE_URL host with `ipaddress` instead of an exact-match
list, so any loopback or unspecified address falls back to the browser
origin, and require an http(s) scheme.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-16 20:28:49 -05:00
Sam Dornan
e64944f2e5 fix(auth): build invite links from ROMM_BASE_URL
The invite link was assembled client-side from window.location.origin, so
generating one while browsing over localhost or a LAN address produced a
link the recipient could not open. The API now returns the full link built
from ROMM_BASE_URL, and the UI falls back to the origin when that setting
points somewhere non-shareable.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-16 20:23:57 -05:00
Georges-Antoine Assi
304d3dd1b9 Merge pull request #4216 from rommapp/fix/state-upload-hidden-rom-visibility
fix(states): enforce ROM visibility when uploading a state
2026-08-16 19:28:58 -04:00
Georges-Antoine Assi
5e7913ecb8 Merge pull request #4215 from rommapp/copilot/add-xdelta-support
Add `.xdelta` support to server-side ROM patcher and v2 patcher UI
2026-08-16 19:28:26 -04:00
Georges-Antoine Assi
4734352349 Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-08-16 19:04:00 -04:00
copilot-swe-agent[bot]
63b98b1c2a feat(patcher): add xdelta patch extension support
Co-authored-by: gantoine <3247106+gantoine@users.noreply.github.com>
2026-08-16 23:01:06 +00:00
Georges-Antoine Assi
b518e7526f fix(states): enforce ROM visibility when uploading a state
Uploading a state fetched the ROM without checking it is visible to the
caller, so an ASSETS_WRITE holder could write against a ROM hidden from
them and tell an existing rom_id from a missing one by the 404. The
download path already guards this boundary; the upload path now matches.

The ROM was fetched twice with an identical 404 block, and the first
states_path was recomputed before use, so both collapse into the single
guarded fetch.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-16 19:00:10 -04:00
copilot-swe-agent[bot]
c1b1cdd540 fix: suppress uvicorn.access logs at INFO level by default
Co-authored-by: gantoine <3247106+gantoine@users.noreply.github.com>
2026-08-16 22:18:50 +00:00
Georges-Antoine Assi
76da6dffd0 Merge branch 'master' into claude/quick-scan-platform-perf-2305c0
# Conflicts:
#	backend/tests/endpoints/sockets/test_scan.py
2026-08-16 17:18:36 -04:00
Georges-Antoine Assi
427510082d Merge pull request #4206 from sdornan/claude/normalize-region-language-tags
fix(scan): normalize region and language tags to one canonical spelling
2026-08-16 16:55:01 -04:00
Georges-Antoine Assi
a1d2cb0d4f fix(scan): keep an empty "Reg-" tag out of the region facet
A "Reg-" prefix with nothing behind it stored an empty string as a
region. It now falls through to the ordinary tags like any other
unrecognized value.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-16 16:47:49 -04:00
Georges-Antoine Assi
9b9dba0dfe fix(scan): drop region aliases and the tag backfill migrations
Region tags now resolve only through the canonical REGIONS names and
shortcodes, so alternate spellings such as (US) or (EU) stay plain tags.
Existing rows keep whatever parse_tags wrote for them.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-16 16:40:12 -04:00
Georges-Antoine Assi
8f3460e820 Merge pull request #4198 from XenuIsWatching/fix/scan-memory-and-listing-perf
perf(scan): cut scan memory and drop a quadratic file listing check
2026-08-16 14:22:57 -04:00
Georges-Antoine Assi
0afc1bf191 Merge pull request #4188 from sdornan/claude/single-file-rescan-perf-483f79
perf(scan): scope a rom-id scan to the selected roms
2026-08-16 13:57:51 -04:00
Georges-Antoine Assi
77d4db5209 Merge pull request #4181 from justinjd00/fix/moby-double-url-encoding
fix: remove double URL-encoding of MobyGames search terms
2026-08-16 12:34:34 -04:00
Sam Dornan
c2b3fec4d6 fix(scan): stat firmware where it was enumerated, not where the row says
The skip path stat'd the firmware row's persisted file_path. That path is
only refreshed by scan_firmware, so a change in the library layout (a
has_structure_path_b flip, a FIRMWARE_FOLDER_NAME change, a platform slug
rebinding) left it pointing at a file that is no longer there. Nothing
catches the resulting FileNotFoundError until scan_platforms, so an
ordinary scan died with scan:done_ko where it previously healed the row.

Derive the path from platform.fs_slug, the same way scan_firmware does and
the same way the enumeration that produced fs_fw did. A row recorded against
a different path is rehashed rather than skipped, which is what refreshes it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-16 11:11:42 -05:00
Georges-Antoine Assi
36295e6ad7 fix: narrow await_args before attribute access in moby handler tests
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-16 12:11:41 -04:00
Sam Dornan
0e6131dc49 perf(scan): stop re-hashing unchanged firmware on every scan
_should_get_rom_files only re-reads a ROM's bytes for a new entry or a
COMPLETE/HASHES scan, so UPDATE, UNMATCHED, QUICK and NEW_PLATFORMS scans
leave existing files alone. Firmware had no equivalent gate: every scan of
every type read and hashed every BIOS file on the platform, serially, even
though a quick scan is described to users as "Scan new games only".

Add _should_hash_firmware alongside its ROM counterpart and apply the same
rule, confirming the file is unchanged by size before the skip. The database
row is consulted first, so an entry that could never be skipped costs no
stat, and missing_from_fs is only written when it actually flips.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-16 10:57:30 -05:00
Georges-Antoine Assi
e1de724421 chore: trim comments in moby_handler
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-16 11:33:34 -04:00
Georges-Antoine Assi
c8c6a5d997 Merge pull request #4163 from sdornan/claude/github-issue-4159-archive-read-errors
fix(hashing): surface unreadable zip and tar archives
2026-08-16 09:02:51 -04:00
Georges-Antoine Assi
3cf6e43a66 test(hashing): fix reader type in archive read failure test
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-16 08:50:16 -04:00
Georges-Antoine Assi
e37dfd5ce9 Merge pull request #4162 from sdornan/claude/github-issue-4157-3f916e
feat(hasheous): map famicom to the NES platform
2026-08-16 08:38:34 -04:00
Georges-Antoine Assi
d7913f4468 Merge pull request #4156 from sdornan/claude/github-issue-4128-134860
fix(export): stop miximage_v2 colliding with miximage, persist gamelist back covers
2026-08-16 08:30:28 -04:00
Sam Dornan
17b20ba423 fix(scan): canonicalize legacy collection criteria and bound migration memory
Review follow-ups on the region and language normalization.

Smart collections created by early versions store a single value under
`selected_region` / `selected_language` rather than a list, and
get_smart_collection_criteria still reads those keys. The migrations only
rewrote the list-valued ones, so a legacy collection kept filtering on "US"
against rows that had become "USA" and silently matched nothing. Both keys
are now handled, preserving each value's scalar or list shape.

The roms backfill also loaded every tagged row before writing anything, so
peak memory scaled with the library on a migration that runs at startup. It
now walks the table by id, holding one batch at a time. The collections pass
still reads in one go: that is one row per user-created collection.

Also strip the "Reg-" capture, since the separator class doesn't swallow a
following space and "[Reg- PAL]" stored " PAL" as its own facet value, and
add a test enforcing the REGION_ALIASES constraint that was only a comment.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-15 19:18:31 -05:00
Sam Dornan
5d565d3ae0 fix(scan): normalize region and language tags to one canonical spelling
parse_tags only canonicalized a region or language written as a shortcode.
A tag written as a name kept the filename's casing, and a "Reg-" prefixed
code outside the shortcode table was stored verbatim, so one library could
hold "USA", "usa", "Usa" and "US" as four values. Each became its own entry
in the filter dropdowns and its own bucket in the platform stats.

Both kinds now resolve through a case-insensitive lookup, with a region
alias table for the spellings the frontend's regionToEmoji already knew
about (US, EU, EUR, JP, BRA, CHN, GLOBAL) plus WR for World.

The region pass runs before the language pass but after both exact-code
checks, because Nl/NL and No/NO differ only by case: exact matching keeps
Dutch and Norwegian, and a lowercased "nl" resolves to the region.

Migrations 0108 and 0109 rewrite rows scanned before this. They also
normalize smart_collections.filter_criteria, whose saved values are
exact-matched against roms.regions, so a collection filtering on "US"
would otherwise silently match nothing. roms_facets follows through the
triggers added in 0100.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-15 19:01:00 -05:00
Georges-Antoine Assi
de28f574f1 Merge pull request #4146 from Spinnich/fix/archive-member-hash-lookup
fix(metadata): identify archives and folder ROMs by the right file
2026-08-15 17:19:05 -04:00
Ryan McClelland
def2d441cb fix(gamelist): drop partial results when a document is unparseable
Streaming means valid entries are consumed before the parser reaches
any damage further down the file, so a truncated or corrupt gamelist
returned whatever had been read so far. The previous full-document
parse rejected such a file outright and imported nothing.

Clear the accumulated entries when a parse error escapes both the
incremental pass and the fallback, restoring that behavior. Errors
raised while building an entry still keep what was read, as before.

Also filter the fallback path to game/folder elements so it matches the
incremental path, and hoist the lowercase filename and suffix tuple out
of the per-extension loop in exclude_single_files.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TLTDjv3niosCXZWtjKELK2
2026-08-14 12:22:28 -07:00
Ryan McClelland
28be8b7ad8 perf(gamelist): parse gamelist.xml incrementally
_parse_gamelist_xml read the whole file, ran two regex rewrites over it
and built a tree for the entire document before touching a single game.
On a platform with thousands of entries that tree dominates the scan's
memory, and it is discarded as soon as the per-game dict is built.

Stream top-level game/folder elements with iterparse instead, clearing
each once consumed. Measured on a synthetic 4.8 MB gamelist with 10,703
games, peak allocation drops from 33.3 MB to 3.4 MB.

ES-DE writes an <alternativeEmulator> sibling to <gameList>, which is
invalid multi-root XML that the incremental parser rejects, so those
files fall back to the previous strip-then-parse path. Entries are keyed
by filename, so re-reading elements already consumed before the failure
cannot corrupt the result.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TLTDjv3niosCXZWtjKELK2
2026-08-14 09:11:11 -07:00
Ryan McClelland
9da03db857 perf(scan): build filesystem ROM entries in a single pass
get_roms built a list of plain dicts for every entry, then rebuilt the
whole thing as FSRom instances and handed that to sorted(). Both lists
are alive at once, so a platform folder holding tens of thousands of
files carries two full copies plus the sorted output.

Build FSRom directly and sort in place. The nested flag is simply the
inverse of flat, so it no longer needs to be carried through an
intermediate dict.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TLTDjv3niosCXZWtjKELK2
2026-08-14 09:11:11 -07:00
Ryan McClelland
9fe43c903e perf(scan): drop quadratic file exclusion check
exclude_single_files collected every excluded name into a list, then
filtered the input against it with `f not in excluded_files`. That
membership test rescans the list once per file, so a platform folder
holding tens of thousands of loose files spends most of the call in
list scans rather than pattern matching.

Decide per file in a single pass instead. Behavior is unchanged,
including for duplicate file names.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TLTDjv3niosCXZWtjKELK2
2026-08-14 09:03:22 -07:00
Sam Dornan
13a771b97f fix(scan): honour a stop mid-scan and drop unscannable roms from totals
`_identify_rom` returns rather than raises when the stop flag is set, so a
scoped scan stopped after it began would finish its gather, fall through to
the post-scan work and emit `scan:done`, leaving the flag set behind it. A
library scan is shielded by the next platform's own check; a scoped scan of
a single platform, which is what the refresh-metadata dialog sends, has no
such next call. Re-check the flag after the gather.

The scoped totals also counted roms whose platform row is gone, which the
scan loop then skipped, so the tracker could never reach its own total.
Drop those roms once, up front, and let the totals and the loop read from
the same dict.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-11 15:14:37 -05:00
Sam Dornan
b1c0dacb9f perf(scan): scope a rom-id scan to the selected roms
A scan with `roms_ids` set only narrowed which roms get metadata, not the
work around them: it still listed the platform folder, re-resolved the
platform's metadata, re-hashed every firmware file, synced the whole
platform's missing-file state twice, and walked every other rom in batches
to mark it present. Rescanning one file therefore cost time proportional to
the platform, not to the file.

Resolve a scoped scan's work from the database instead, via a new
`_scan_selected_roms` that skips all of the platform-wide reconciliation.
The gamelist cache warm-up stays, since hash matching reads from it.

`refresh_smart_collections` was likewise recomputing every smart collection
across the whole library after any scan; a scoped one now uses the targeted
`refresh_smart_collections_for_roms`.

A library scan never reaches an entry whose file is gone, since it walks the
filesystem. A database-driven one does, and scanning marks a rom present
unconditionally, so the scoped path checks the path first and marks it
missing rather than resurrecting it. That check needs `directory_exists`
alongside `file_exists`, which also derives `flat`/`nested` for the `FSRom`
a library scan gets from splitting its listing.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-11 15:01:00 -05:00
Justin
8f809a10a6 fix: remove double URL-encoding of MobyGames search terms
The MobyGames handler pre-encoded search terms with urllib's quote()
before passing them to MobyGamesService.list_games(), which encodes the
query itself via yarl's with_query(). Titles containing special
characters were therefore double-encoded and never matched:

    'Sonic & Knuckles'  -> title=Sonic+%2526+Knuckles
    '... World + Bowser's Fury' -> title=...+%252B+Bowser%2527s+Fury

Pass the raw (unidecoded) term and let the service layer encode it
exactly once, matching how the ScreenScraper handler already works.
Adds regression tests for both the scan path (_search_rom) and the
manual-search path (get_matched_roms_by_name).

Same bug class as reported for ScreenScraper in #3467.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-10 19:05:48 +02:00
Sam Dornan
76303abaec test(hashing): cover tar read failures
Truncated tars surface while listing, since `getmembers()` walks the whole
archive before any member is streamed, so the streaming guard is covered
directly for the archive types that share it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-08 16:50:31 -05:00
Sam Dornan
f15ec3e42d fix(hashing): surface unreadable zip and tar archives
The zip and tar readers swallowed read failures and returned an empty
iterator, which the hashing path can't tell apart from an empty archive:
it falls back to hashing the container's raw bytes, so the ROM gets
hashes that match no hash database and nothing explains why.

Raise ArchiveReadError instead, as the 7z and rar readers already do, so
the fallback is logged. Member streaming is now wrapped too, since chunks
are consumed outside the reader's error handling and a bad CRC escaped as
a raw zipfile error rather than falling back.

Fixes #4159

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-08 16:05:23 -05:00
Sam Dornan
217d52ac72 feat(hasheous): map famicom to the NES platform
Hasheous has no separate Famicom data object; its NES platform (68) holds
the NES/Famicom signature sets. Without a mapping, the scan skipped the
Hasheous lookup entirely for Famicom ROMs, since it gates on hasheous_id.

Fixes #4157

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-08 15:52:33 -05:00
Sam Dornan
eed6c8786b fix(export): stop miximage_v2 colliding with miximage, persist gamelist back covers
miximage and miximage_v2 both mapped to the assets/miximages directory and to
the <miximage> tag, so the v2 art was dropped by the existing-destination
short-circuit in _copy_asset and the XML carried a duplicate tag. Route the v2
variant to assets/miximages_v2 and the <miximage_v2> tag, matching the folder
and tag the gamelist handler already reads back.

The gamelist handler discovers back covers and fanart (ES-DE backcovers/ and
fanart/ folders, <backcover> and <fanart> tags) but never recorded a local
path for them, so the gl.get("box2d_back_path") / gl.get("fanart_path")
fallbacks in both exporters could never resolve. Record those paths alongside
the media types the handler already persists, and declare title_screen_path,
which populate_rom_specific_paths already emitted.

Fixes #4128
2026-08-08 11:44:13 -05:00
Georges-Antoine Assi
392cc9b0e2 Merge pull request #4143 from Spinnich/fix/cover-downloaded-twice
fix(resources): fetch each cover once instead of once per size
2026-08-08 12:05:48 -04:00
Georges-Antoine Assi
97b3a32148 cleanup 2026-08-08 11:23:53 -04:00
Georges-Antoine Assi
0f9d2fc53b Merge pull request #4139 from sdornan/claude/github-issue-4127-dd46eb
fix(ss): store the ScreenScraper box-2D front locally
2026-08-07 18:59:15 -04:00
Georges-Antoine Assi
30a04e088e Merge pull request #4125 from sdornan/claude/hltb-api-503-error-806ce9
fix(hltb): renew rejected HLTB sessions instead of failing the scan
2026-08-07 14:50:13 -04:00
Georges-Antoine Assi
e8993c1d4d run fmt 2026-08-07 14:37:11 -04:00
Georges-Antoine Assi
a5854b557e Merge pull request #4121 from sdornan/claude/launchbox-n64-matching-b7ce16
fix(launchbox): match ROMs during a scan the way Match ROM does
2026-08-07 11:24:23 -04:00