A rehashed ROM whose new hashes no longer match Hasheous kept its old
`hasheous_id` and `hasheous_metadata`: the merge loop only writes truthy
values, so an empty match cannot overwrite the values seeded from the
existing ROM, and the verification flags stayed on a ROM that no longer
earned them.
Clearing on any empty match would be wrong, though: `lookup_rom` returns the
same empty fallback whether Hasheous answered "unknown hashes" or was simply
unreachable (#2236), so an outage would silently de-verify a whole library.
Have `lookup_rom` return whether it reached a definitive answer, mirroring
`meta_ss_handler.lookup_rom`, and only clear the match on a conclusive miss.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
A ROM's "verified" state comes entirely from the Hasheous signature match
flags in `hasheous_metadata`, but `ScanType.HASHES` was missing from both
Hasheous gates in `scan_rom`. A rehash recomputed the file hashes and then
never re-asked Hasheous about them, so the verification chips stayed dark
(#4001). RetroAchievements was already gated in, which is why its provider
icon appeared while nothing lit up.
A follow-up update scan didn't help either: that branch is gated on
`rom.hasheous_id`, which is never set for a ROM that has yet to match.
Add `HASHES` to `fetch_hasheous_hash_match` and `fetch_hasheous_rom`, and
to the "don't overwrite existing base fields" branch: Hasheous now returns
a name/cover/summary on a rehash, and `_identify_rom` short-circuits before
the cover download, so a changed `url_cover` would point at an image that
is never fetched.
Fixes#4001
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Four points from the PR review:
- Leave the process-global ScreenScraper state alone when a scan does not use
ScreenScraper. DEV_MODE runs scans in-process, so overlapping scans could
otherwise clear each other's learned limits and skipped ROMs.
- Return pacing to the defaults when the per-scan state resets. Priming re-reads
the account moments later; should that fail, the conservative default is safe
for whatever account the credentials now name, whereas the previous scan's
allowance may be more than this one is entitled to.
- Stop a rate-limited ROM from trying the next lookup. A refusal that survives
the retry now propagates out of the handler and is caught once per ROM in
fetch_ss_rom, instead of being swallowed per call site and sending the caller
on to spend another retried request against a budget that is already gone.
_is_daily_quota_error excludes the rate-limit 429 so the two stay distinct.
- Hand the request slot back before inspecting and re-encoding a cover, so
local image work no longer holds a ScreenScraper thread.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
HasheousHandler.lookup_rom and SGDBBaseHandler.get_details_by_names now
resolve to an empty match instead of raising, matching the best-effort
pattern already used by PlaymatchHandler.lookup_rom and
SGDBBaseHandler.get_rom_by_id, so one failing provider can't abort a
scan or discard the other providers' results (#2236).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Move the quota-skip decision out of scan_handler and into the SS handler:
lookup_rom, get_rom, and get_rom_by_id now catch the daily-quota 429 and
return an empty SSRom, so the scan degrades to the other providers with no
quota-specific code at the call site. Non-429 errors still propagate.
scan_handler keeps only the fault-tolerant provider gather. The service
breaker still short-circuits repeat calls and manual search still surfaces
the 429 (it does not go through these swallow paths for name search).
Generated-By: PostHog Code
Task-Id: 77dff3d9-6120-4156-bb25-1556a50a75e4
Track the ScreenScraper daily quota where the knowledge lives: a breaker
in the service, tripped on the first HTTP 430/431 and reset at the start
of each scan. When tripped, _request() short-circuits the API call but
still raises the 429, so manual search keeps its clear "quota exhausted"
message while the scan catches it and falls back to the other providers.
Replaces the handler-level skip flag with this service-scoped breaker.
Generated-By: PostHog Code
Task-Id: 77dff3d9-6120-4156-bb25-1556a50a75e4
Move the "skip this provider for the rest of the scan" state off a set
threaded through scan_rom and onto the MetadataHandler base class, so each
provider tracks it internally. The state is cleared for every provider at
the start of each scan via reset_metadata_handlers_scan_state().
Generated-By: PostHog Code
Task-Id: 77dff3d9-6120-4156-bb25-1556a50a75e4
Background scans usually run with RomM closed, so the scan:warning toast
would rarely be seen. Keep the backend skip/fallback behavior and the log
line, and remove the socket event, its frontend handler, and the i18n key.
Generated-By: PostHog Code
Task-Id: 77dff3d9-6120-4156-bb25-1556a50a75e4
When a user hit ScreenScraper's daily API quota mid-scan, the whole scan
stopped matching ROMs against every provider instead of just skipping SS.
The 429 raised for SS quota (HTTP 430/431) propagated out of the per-ROM
provider gather (which lacked return_exceptions), discarding the other
providers' results, and every subsequent ROM re-hit the exhausted API.
- Skip ScreenScraper for the rest of the scan on the first quota hit,
tracked in a shared per-scan set, so remaining ROMs stop hammering it.
- Keep the current ROM's other-provider data when SS quota is hit.
- Make the provider gather fault-tolerant (return_exceptions) so one
provider raising never discards the others' results.
- Notify the user once via a non-fatal scan:warning socket toast.
The manual-search path still surfaces the 429 quota message unchanged.
Fixes#3620
Generated-By: PostHog Code
Task-Id: 77dff3d9-6120-4156-bb25-1556a50a75e4
name is NotRequired[str] on HasheousRom, so passing name=None fails mypy's
typeddict-item check. Omit it to represent a no-match result.
Generated-By: PostHog Code
Task-Id: 987bb9c1-1bfb-43f2-adc7-c26e69f06a39
A ROM's name defaults to its raw filename (extension included) when it is
first discovered. On UNMATCHED and UPDATE rescans, the block that preserves
existing base fields kept that placeholder name even after a metadata
provider finally matched the ROM, leaving the filename (with its ".zip"
extension and region tags) as the title.
Treat a name equal to the ROM's filename as "no name" so a freshly matched
provider name replaces it, while still preserving user-edited names.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Shf4omKSP6dHC3dC2Jjg7b
Match the json-patch camelCase key names the Hasheous endpoint expects,
and update the lookup_rom test assertions accordingly.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The Hasheous ByHash endpoint now accepts an array of hash objects rather
than a single one. Send the hashes of every top-level file (using
chd_sha1_hash exclusively for files that have one) to improve lookup
accuracy, instead of picking only the largest file.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
When a user manually sets metadata IDs (e.g., ra_id, launchbox_id, hasheous_id)
via the UI and then runs "Refresh Metadata" (which defaults to UNMATCHED scan type),
no metadata was fetched because UNMATCHED conditions checked `not rom.xxx_id` — so
if the ID was already set, the handler was skipped entirely.
Fix: Change each handler's UNMATCHED condition to also trigger when the ID is set
but the corresponding metadata dict is empty (i.e., `not rom.xxx_id or not rom.xxx_metadata`).
For handlers that support ID-based lookup (RA, Launchbox, IGDB, MobyGames, SS,
Flashpoint), also add the `get_rom_by_id` path inside the function.
For Hasheous: when hash lookup fails but `hasheous_id` is set on an existing ROM
(not newly added), return a partial HasheousRom built from the existing sub-IDs
(igdb_id, ra_id, tgdb_id) so the downstream get_igdb_game / get_ra_game proxy
calls can still enrich the ROM.
Add three targeted tests to validate:
- UNMATCHED scan fetches RA metadata when ra_id is set but ra_metadata is empty
- UNMATCHED scan skips RA when both ra_id and ra_metadata are already populated
- UNMATCHED scan passes existing sub-IDs to Hasheous proxies when hash lookup fails
Agent-Logs-Url: https://github.com/rommapp/romm/sessions/098b482f-9f73-4f35-819a-b55004a79b13
Co-authored-by: gantoine <3247106+gantoine@users.noreply.github.com>