mirror of
https://github.com/rommapp/romm.git
synced 2026-11-28 17:48:31 +01:00
Merge pull request #4013 from rommapp/fix/hashes-scan-rematches-hasheous
fix(backend): re-run the Hasheous hash lookup on a hashes scan
This commit is contained in:
@@ -444,13 +444,14 @@ async def scan_rom(
|
||||
gamelist_id=None,
|
||||
)
|
||||
|
||||
async def fetch_hasheous_hash_match() -> HasheousRom:
|
||||
async def fetch_hasheous_hash_match() -> tuple[HasheousRom, bool]:
|
||||
if (
|
||||
MetadataSource.HASHEOUS in metadata_sources
|
||||
and platform.hasheous_id
|
||||
and (
|
||||
newly_added
|
||||
or scan_type == ScanType.COMPLETE
|
||||
or scan_type == ScanType.HASHES
|
||||
or (scan_type == ScanType.UPDATE and rom.hasheous_id)
|
||||
or (
|
||||
scan_type == ScanType.UNMATCHED
|
||||
@@ -463,7 +464,10 @@ async def scan_rom(
|
||||
platform.slug, get_match_files()
|
||||
)
|
||||
|
||||
return HasheousRom(hasheous_id=None, igdb_id=None, tgdb_id=None, ra_id=None)
|
||||
return (
|
||||
HasheousRom(hasheous_id=None, igdb_id=None, tgdb_id=None, ra_id=None),
|
||||
False,
|
||||
)
|
||||
|
||||
_added_rom = db_rom_handler.add_rom(Rom(**rom_attrs))
|
||||
_added_rom.is_identifying = True
|
||||
@@ -488,7 +492,7 @@ async def scan_rom(
|
||||
# Run hash fetches concurrently
|
||||
(
|
||||
playmatch_hash_match,
|
||||
hasheous_hash_match,
|
||||
(hasheous_hash_match, hasheous_lookup_conclusive),
|
||||
) = await asyncio.gather(
|
||||
fetch_playmatch_hash_match(),
|
||||
fetch_hasheous_hash_match(),
|
||||
@@ -817,6 +821,7 @@ async def scan_rom(
|
||||
and (
|
||||
newly_added
|
||||
or scan_type == ScanType.COMPLETE
|
||||
or scan_type == ScanType.HASHES
|
||||
or (scan_type == ScanType.UPDATE and rom.hasheous_id)
|
||||
or (
|
||||
scan_type == ScanType.UNMATCHED
|
||||
@@ -1014,9 +1019,11 @@ async def scan_rom(
|
||||
if field_value:
|
||||
rom_attrs[field] = field_value
|
||||
|
||||
# Don't overwrite existing base fields on update and unmatched scans
|
||||
if not newly_added and (
|
||||
scan_type == ScanType.UNMATCHED or scan_type == ScanType.UPDATE
|
||||
# Don't overwrite existing base fields on update, unmatched and hashes scans
|
||||
if not newly_added and scan_type in (
|
||||
ScanType.UNMATCHED,
|
||||
ScanType.UPDATE,
|
||||
ScanType.HASHES,
|
||||
):
|
||||
# A ROM's name defaults to a filename-derived placeholder when first
|
||||
# created. Treat that placeholder as "no name" so a freshly matched provider
|
||||
@@ -1048,6 +1055,18 @@ async def scan_rom(
|
||||
}
|
||||
)
|
||||
|
||||
# A rehash that no longer matches must drop the previous Hasheous match, or
|
||||
# the ROM keeps showing verification flags earned by hashes it no longer has.
|
||||
# Only a conclusive lookup clears them, so an unreachable Hasheous can't
|
||||
# silently de-verify a library.
|
||||
if (
|
||||
scan_type == ScanType.HASHES
|
||||
and hasheous_lookup_conclusive
|
||||
and not hasheous_hash_match.get("hasheous_id")
|
||||
):
|
||||
rom_attrs["hasheous_id"] = None
|
||||
rom_attrs["hasheous_metadata"] = {}
|
||||
|
||||
# Use PICO-8 cartridge PNG as cover art if no cover is set.
|
||||
# PICO-8 .p8.png files are valid PNG images whose visual content is the
|
||||
# cartridge label, so the ROM file itself serves as the cover art.
|
||||
|
||||
Reference in New Issue
Block a user