Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix scans when running HASH_SCAN #1081

Merged
merged 2 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions backend/alembic/versions/0025_roms_hashes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)


Expand Down
6 changes: 5 additions & 1 deletion 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 @@ -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,
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
Loading