Skip to content

Commit

Permalink
run quick before hash scan
Browse files Browse the repository at this point in the history
  • Loading branch information
gantoine committed Aug 12, 2024
1 parent e24a3b8 commit b3a5002
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
6 changes: 5 additions & 1 deletion backend/alembic/versions/0025_roms_hashes.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ def upgrade() -> None:
# 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
)


Expand Down
4 changes: 2 additions & 2 deletions backend/endpoints/sockets/scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -342,7 +342,7 @@ 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.HASH_SCAN:
if scan_type == ScanType.HASHES:
return scan_stats

path_cover_s, path_cover_l = await fs_resource_handler.get_cover(
Expand Down
6 changes: 3 additions & 3 deletions backend/handler/scan_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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():
Expand Down

0 comments on commit b3a5002

Please sign in to comment.