Send all top-level file hashes to Hasheous lookup#3498
Conversation
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>
There was a problem hiding this comment.
Pull request overview
Updates the Hasheous metadata lookup to use the new Lookup/ByHash array payload by sending hashes for all qualifying top-level ROM files (including CHD-specific handling), improving match accuracy and avoiding requests when no usable hashes exist.
Changes:
HasheousHandler.lookup_romnow builds and sends a list of per-file hash objects (CHD usessha1fromchd_sha1_hashonly; other files sendmd5/sha1/crcwith empty values removed)._requestnow acceptsdict | list | Nonefor JSON payloads.- Added tests to validate the list payload and the “skip request if no hashes” behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| backend/handler/metadata/hasheous_handler.py | Switches Hasheous ByHash lookup from a single-hash payload to a list of hashes across all top-level files, with CHD-specific hashing behavior. |
| backend/tests/handler/test_fastapi.py | Adds coverage ensuring the full list payload is sent and that requests are skipped when no usable hashes are available. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
☂️ Python Coverage
Overall Coverage
New FilesNo new covered files... Modified Files
|
Annotate request_kwargs as dict[str, Any] to accept the list json payload, and file_hashes as dict[str, str | None] so the chd_sha1_hash branch and the md5/sha1/crc branch unify cleanly. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Regarding:
Although it's (supposed to be) case insensitive, I would stick with the original casing. |
Summary
The Hasheous
Lookup/ByHashendpoint now accepts an array of hash objects instead of a single one. This updatesHasheousHandler.lookup_romto send the hashes of every top-level file, rather than picking only the largest file and sending its single hash set.Changes
lookup_romnow builds a list payload, one entry per qualifying top-level file:chd_sha1_hashsend only{"sha1": <chd_sha1_hash>}— the raw container MD5/CRC won't match what Hasheous indexes for CHDs.{"md5", "sha1", "crc"}.md5/sha1/crc) matching the array payload format, replacing the old single-object camelCase keys (mD5/shA1)._requestsignature widened to acceptdict | list | Nonefor the list payload.Tests
test_lookup_rom_sends_all_top_level_file_hashes— verifies the full list payload, chd_sha1_hash-only handling, and that zero-size / hashless files are filtered.test_lookup_rom_skips_request_when_no_hashes— verifies the API isn't hit when no hashes are available.🤖 Generated with Claude Code