From 8c817c7f4b1a41a479751dc08b102c737f4a258a Mon Sep 17 00:00:00 2001 From: Georges-Antoine Assi Date: Thu, 5 Jun 2025 11:44:47 -0400 Subject: [PATCH] stop RA from crashing when not available --- backend/adapters/services/rahasher.py | 18 ++++++++++++------ .../handler/filesystem/resources_handler.py | 2 +- backend/handler/scan_handler.py | 5 +++-- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/backend/adapters/services/rahasher.py b/backend/adapters/services/rahasher.py index 6c9894879..1f372db7a 100644 --- a/backend/adapters/services/rahasher.py +++ b/backend/adapters/services/rahasher.py @@ -94,12 +94,18 @@ class RAHasherService: f"Executing {hl('RAHasher', color=LIGHTMAGENTA)} for platform: {hl(RA_ID_TO_SLUG[platform_id])} - file: {hl(file_path.split('/')[-1])}" ) args = (str(platform_id), file_path) - proc = await asyncio.create_subprocess_exec( - "RAHasher", - *args, - stdout=asyncio.subprocess.PIPE, - stderr=asyncio.subprocess.PIPE, - ) + + try: + proc = await asyncio.create_subprocess_exec( + "RAHasher", + *args, + stdout=asyncio.subprocess.PIPE, + stderr=asyncio.subprocess.PIPE, + ) + except FileNotFoundError: + log.error("RAHasher executable not found in PATH") + return "" + return_code = await proc.wait() if return_code != 1: if proc.stderr is not None: diff --git a/backend/handler/filesystem/resources_handler.py b/backend/handler/filesystem/resources_handler.py index 67b9a8a66..4f6243efb 100644 --- a/backend/handler/filesystem/resources_handler.py +++ b/backend/handler/filesystem/resources_handler.py @@ -147,7 +147,7 @@ class FSResourcesHandler(FSHandler): shutil.rmtree(cover_path) except FileNotFoundError: log.warning( - f"Couldn't remove cover from '{hl(entity.name or entity.id, color=BLUE)}' since '{cover_path}' doesn't exists." + f"Couldn't remove cover from '{hl(entity.name or str(entity.id), color=BLUE)}' since '{cover_path}' doesn't exists." ) return {"path_cover_s": "", "path_cover_l": ""} diff --git a/backend/handler/scan_handler.py b/backend/handler/scan_handler.py index 6dac46170..6dfa6e70a 100644 --- a/backend/handler/scan_handler.py +++ b/backend/handler/scan_handler.py @@ -160,6 +160,7 @@ async def scan_platform( platform_attrs["igdb_id"] or platform_attrs["moby_id"] or platform_attrs["ss_id"] + or platform_attrs["ra_id"] ): log.info( emoji.emojize( @@ -264,12 +265,12 @@ async def scan_rom( "summary": rom.summary, "igdb_metadata": rom.igdb_metadata, "moby_metadata": rom.moby_metadata, - "url_cover": rom.url_cover, - "url_manual": rom.url_manual, "path_cover_s": rom.path_cover_s, "path_cover_l": rom.path_cover_l, "path_screenshots": rom.path_screenshots, + "url_cover": rom.url_cover, "url_screenshots": rom.url_screenshots, + "url_manual": rom.url_manual, } )