Files
romm/backend/handler/metadata
Sam Dornan 420ccbc38a fix(hasheous): match multi-file roms when one file is unknown (#4846)
* fix(hasheous): match multi-file roms when one file is unknown

Hasheous' /Lookup/ByHash returns 404 for a batch as soon as any one SHA-1
in it is unknown, even when the rest match. A multi-disc CHD set with an
.m3u, a readme or an off-set disc beside it therefore never matched, e.g.
Final Fantasy VII (USA), whose three MAMERedump CHD hashes match on their
own.

- Leave .m3u playlists out of the lookup.
- When a multi-file batch misses, retry each file on its own, largest
  first, and take the first match.
- Read the TheGamesDB id from "TheGamesDb", the spelling Hasheous returns,
  so tgdb_id is no longer always dropped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TZeLXgA178Biwj7eUReck4

* fix(hasheous): require per-file matches to agree on one game

The per-file retry took the first file Hasheous knew, so a folder holding
an unknown game next to a known file from another game (a demo disc, a
bonus CD) could take on that other game's ids. Every file is now asked
and the match stands only when all known files name the same game;
conflicting answers match nothing and leave the lookup inconclusive.

A failed per-file request still ends the lookup as inconclusive, since
agreement can't be vouched for without every answer. The largest-first
ordering is gone, as nothing depends on the order any more.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TZeLXgA178Biwj7eUReck4

* test(hasheous): expect the per-file retry after a missed batch

test_lookup_rom_sends_all_top_level_file_hashes mocks a miss for two
files, which now also asks Hasheous about each file alone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TZeLXgA178Biwj7eUReck4

* test(hasheous): build lookup fixtures as real RomFiles

The lookup tests cast MagicMocks to RomFile, which would hand lookup_rom
attributes a real RomFile lacks. They now build RomFiles, so file_extension
and lookup_hashes come from the model itself.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TZeLXgA178Biwj7eUReck4

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-27 13:45:09 -05:00
..