diff --git a/backend/endpoints/sockets/scan.py b/backend/endpoints/sockets/scan.py index 9754ece8e..a7820cf94 100644 --- a/backend/endpoints/sockets/scan.py +++ b/backend/endpoints/sockets/scan.py @@ -340,6 +340,10 @@ async def _identify_rom( for new_rom_file in new_rom_files: db_rom_handler.add_rom_file(new_rom_file) + # Short circuit if the scan type is hashes + if scan_type == ScanType.HASHES: + return + if _added_rom.ra_metadata: for ach in _added_rom.ra_metadata.get("achievements", []): # Store both normal and locked version diff --git a/backend/handler/scan_handler.py b/backend/handler/scan_handler.py index bc712e833..ac0a18fe4 100644 --- a/backend/handler/scan_handler.py +++ b/backend/handler/scan_handler.py @@ -289,21 +289,27 @@ async def scan_rom( newly_added: bool, socket_manager: socketio.AsyncRedisManager | None = None, ) -> Rom: - filesize = sum([file.file_size_bytes for file in fs_rom["files"]]) rom_attrs = { "platform_id": platform.id, "name": fs_rom["fs_name"], "fs_name": fs_rom["fs_name"], - "crc_hash": fs_rom["crc_hash"], - "md5_hash": fs_rom["md5_hash"], - "sha1_hash": fs_rom["sha1_hash"], - "ra_hash": fs_rom["ra_hash"], - "fs_size_bytes": filesize, "url_cover": "", "url_manual": "", "url_screenshots": [], } + if len(fs_rom["files"]) > 0: + filesize = sum([file.file_size_bytes for file in fs_rom["files"]]) + rom_attrs.update( + { + "crc_hash": fs_rom["crc_hash"], + "md5_hash": fs_rom["md5_hash"], + "sha1_hash": fs_rom["sha1_hash"], + "ra_hash": fs_rom["ra_hash"], + "fs_size_bytes": filesize, + } + ) + if rom: rom_attrs.update( {