mirror of
https://github.com/rommapp/romm.git
synced 2026-06-28 06:46:00 +00:00
[HOTFIX] Fix nightly scans resetting igdb/moby IDs
This commit is contained in:
@@ -46,7 +46,7 @@ async def scan_platforms(
|
||||
platform_ids: list[int],
|
||||
scan_type: ScanType = ScanType.QUICK,
|
||||
selected_roms: list[str] = (),
|
||||
metadata_sources: list[str] = (),
|
||||
metadata_sources: list[str] = ["igdb", "moby"],
|
||||
):
|
||||
"""Scan all the listed platforms and fetch metadata from different sources
|
||||
|
||||
@@ -54,7 +54,7 @@ async def scan_platforms(
|
||||
platform_slugs (list[str]): List of platform slugs to be scanned
|
||||
scan_type (str): Type of scan to be performed. Defaults to "quick".
|
||||
selected_roms (list[str], optional): List of selected roms to be scanned. Defaults to [].
|
||||
metadata_sources (list[str], optional): List of metadata sources to be used. Defaults to [].
|
||||
metadata_sources (list[str], optional): List of metadata sources to be used. Defaults to all sources.
|
||||
"""
|
||||
|
||||
sm = _get_socket_manager()
|
||||
@@ -90,11 +90,12 @@ async def scan_platforms(
|
||||
if platform and scan_type == ScanType.NEW_PLATFORMS:
|
||||
continue
|
||||
|
||||
scanned_platform = scan_platform(
|
||||
platform_slug, fs_platforms, metadata_sources
|
||||
)
|
||||
scanned_platform = scan_platform(platform_slug, fs_platforms)
|
||||
if platform:
|
||||
scanned_platform.id = platform.id
|
||||
# Keep the existing ids if they exist on the platform
|
||||
scanned_platform.igdb_id = scanned_platform.igdb_id or platform.igdb_id
|
||||
scanned_platform.moby_id = scanned_platform.moby_id or platform.moby_id
|
||||
|
||||
scan_stats.scanned_platforms += 1
|
||||
scan_stats.added_platforms += 1 if not platform else 0
|
||||
|
||||
@@ -133,9 +133,6 @@ class MobyGamesHandler(MetadataHandler):
|
||||
return pydash.get(exact_matches or roms, "[0]", None)
|
||||
|
||||
def get_platform(self, slug: str) -> MobyGamesPlatform:
|
||||
if not MOBY_API_ENABLED:
|
||||
return MobyGamesPlatform(moby_id=None, slug=slug)
|
||||
|
||||
platform = SLUG_TO_MOBY_ID.get(slug, None)
|
||||
|
||||
if not platform:
|
||||
|
||||
@@ -47,7 +47,6 @@ def _get_main_platform_igdb_id(platform: Platform):
|
||||
def scan_platform(
|
||||
fs_slug: str,
|
||||
fs_platforms: list[str],
|
||||
metadata_sources: list[str] = ["igdb", "moby"],
|
||||
) -> Platform:
|
||||
"""Get platform details
|
||||
|
||||
@@ -83,16 +82,8 @@ def scan_platform(
|
||||
except (KeyError, TypeError, AttributeError):
|
||||
platform_attrs["slug"] = fs_slug
|
||||
|
||||
igdb_platform = (
|
||||
igdb_handler.get_platform(platform_attrs["slug"])
|
||||
if "igdb" in metadata_sources
|
||||
else {"igdb_id": None}
|
||||
)
|
||||
moby_platform = (
|
||||
moby_handler.get_platform(platform_attrs["slug"])
|
||||
if "moby" in metadata_sources
|
||||
else {"moby_id": None}
|
||||
)
|
||||
igdb_platform = igdb_handler.get_platform(platform_attrs["slug"])
|
||||
moby_platform = moby_handler.get_platform(platform_attrs["slug"])
|
||||
|
||||
platform_attrs["name"] = platform_attrs["slug"].replace("-", " ").title()
|
||||
platform_attrs.update({**moby_platform, **igdb_platform}) # Reverse order
|
||||
|
||||
@@ -2,6 +2,7 @@ from config import ENABLE_SCHEDULED_RESCAN, SCHEDULED_RESCAN_CRON
|
||||
from endpoints.sockets.scan import scan_platforms
|
||||
from logger.logger import log
|
||||
from tasks.tasks import PeriodicTask
|
||||
from handler.scan_handler import ScanType
|
||||
|
||||
|
||||
class ScanLibraryTask(PeriodicTask):
|
||||
@@ -20,7 +21,7 @@ class ScanLibraryTask(PeriodicTask):
|
||||
return
|
||||
|
||||
log.info("Scheduled library scan started...")
|
||||
await scan_platforms([])
|
||||
await scan_platforms([], scan_type=ScanType.UNIDENTIFIED)
|
||||
log.info("Scheduled library scan done")
|
||||
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ from config import (
|
||||
)
|
||||
from endpoints.sockets.scan import scan_platforms
|
||||
from handler import db_platform_handler
|
||||
from handler.scan_handler import ScanType
|
||||
from logger.logger import log
|
||||
from tasks.tasks import tasks_scheduler
|
||||
from config.config_manager import config_manager as cm
|
||||
@@ -69,7 +70,10 @@ class EventHandler(FileSystemEventHandler):
|
||||
# Otherwise trigger a rescan for the specific platform
|
||||
log.info(f"Change detected in {fs_slug} folder, {rescan_in_msg}")
|
||||
return tasks_scheduler.enqueue_in(
|
||||
time_delta, scan_platforms, [db_platform.id]
|
||||
time_delta,
|
||||
scan_platforms,
|
||||
[db_platform.id],
|
||||
scan_type=ScanType.QUICK,
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user