diff --git a/backend/alembic/versions/0025_roms_hashes.py b/backend/alembic/versions/0025_roms_hashes.py index 7dd5f3659..0d14ade97 100644 --- a/backend/alembic/versions/0025_roms_hashes.py +++ b/backend/alembic/versions/0025_roms_hashes.py @@ -28,10 +28,14 @@ def upgrade() -> None: sa.Column("sha1_hash", sa.String(length=100), nullable=True) ) - # Run a no-scan in the background on startup + # Run a no-scan in the background on migrate if not IS_PYTEST_RUN: high_prio_queue.enqueue( - scan_platforms, [], ScanType.HASH_SCAN, [], [], job_timeout=SCAN_TIMEOUT + scan_platforms, [], ScanType.QUICK, [], [], job_timeout=SCAN_TIMEOUT + ) + + high_prio_queue.enqueue( + scan_platforms, [], ScanType.HASHES, [], [], job_timeout=SCAN_TIMEOUT ) diff --git a/backend/endpoints/sockets/scan.py b/backend/endpoints/sockets/scan.py index 4dc9bb7b8..f66103452 100644 --- a/backend/endpoints/sockets/scan.py +++ b/backend/endpoints/sockets/scan.py @@ -82,7 +82,7 @@ def _should_scan_rom(scan_type: ScanType, rom: Rom, roms_ids: list): return ( (scan_type in {ScanType.NEW_PLATFORMS, ScanType.QUICK} and not rom) or (scan_type == ScanType.COMPLETE) - or (scan_type == ScanType.HASH_SCAN) + or (scan_type == ScanType.HASHES) or ( rom and ( @@ -341,6 +341,10 @@ async def _identify_rom( _added_rom = db_rom_handler.add_rom(scanned_rom) + # Return early if we're only scanning for hashes + if scan_type == ScanType.HASHES: + return scan_stats + path_cover_s, path_cover_l = await fs_resource_handler.get_cover( overwrite=True, entity=_added_rom, diff --git a/backend/handler/scan_handler.py b/backend/handler/scan_handler.py index 9ef7d5e5b..13bc0937e 100644 --- a/backend/handler/scan_handler.py +++ b/backend/handler/scan_handler.py @@ -24,7 +24,7 @@ class ScanType(Enum): UNIDENTIFIED = "unidentified" PARTIAL = "partial" COMPLETE = "complete" - HASH_SCAN = "hash_scan" + HASHES = "hashes" async def _get_main_platform_igdb_id(platform: Platform): @@ -231,12 +231,12 @@ async def scan_rom( ) # Calculating hashes is expensive, so we only do it if necessary - if not rom or scan_type == ScanType.COMPLETE or scan_type == ScanType.HASH_SCAN: + if not rom or scan_type == ScanType.COMPLETE or scan_type == ScanType.HASHES: rom_hashes = fs_rom_handler.get_rom_hashes(rom_attrs["file_name"], roms_path) rom_attrs.update(**rom_hashes) # If no metadata scan is required - if scan_type == ScanType.HASH_SCAN: + if scan_type == ScanType.HASHES: return Rom(**rom_attrs) async def fetch_igdb_rom():