diff --git a/backend/adapters/services/libretro_thumbnails.py b/backend/adapters/services/libretro_thumbnails.py index 3c345c6a0..e085a1ebd 100644 --- a/backend/adapters/services/libretro_thumbnails.py +++ b/backend/adapters/services/libretro_thumbnails.py @@ -34,7 +34,7 @@ class _AnchorHrefParser(HTMLParser): # Skip sort/parent/query links exposed by Apache autoindex. if value.startswith(("?", "/", "#")) or ".." in value: return - # Only keep image files — libretro stores PNGs. + # Only keep image files, since libretro stores PNGs. decoded = unquote(value) if decoded.lower().endswith((".png", ".jpg", ".jpeg", ".webp")): self.filenames.append(decoded) diff --git a/backend/adapters/services/rahasher.py b/backend/adapters/services/rahasher.py index 4eb42164c..c3dbca028 100644 --- a/backend/adapters/services/rahasher.py +++ b/backend/adapters/services/rahasher.py @@ -109,7 +109,7 @@ class RAHasherService: # Skip the subprocess entirely when the file is an archive and the # RA platform needs an on-disk disc image. RAHasher would just spawn, # fail with "Unsupported console for buffer hash: {id}", and return - # nothing — paying process-spawn overhead per ROM for no result. + # nothing, so we'd pay process-spawn overhead per ROM for no result. if file_path.lower().endswith(tuple(COMPRESSED_FILE_EXTENSIONS)): if platform["ra_id"] in RA_BUFFER_HASH_UNSUPPORTED_IDS: log.debug( diff --git a/backend/config/__init__.py b/backend/config/__init__.py index dcb07ac18..67fe0010c 100644 --- a/backend/config/__init__.py +++ b/backend/config/__init__.py @@ -213,7 +213,7 @@ SCHEDULED_RETROACHIEVEMENTS_PROGRESS_SYNC_CRON: Final[str] = _get_env( ) # SYNC -SYNC_BASE_PATH: Final[str] = _get_env("SYNC_BASE_PATH", f"{ROMM_BASE_PATH}/sync") +SYNC_BASE_PATH: Final[str] = f"{ROMM_BASE_PATH}/sync" ENABLE_SYNC_FOLDER_WATCHER: Final[bool] = safe_str_to_bool( _get_env("ENABLE_SYNC_FOLDER_WATCHER") ) @@ -226,10 +226,10 @@ SYNC_PUSH_PULL_CRON: Final[str] = _get_env( "*/30 * * * *", # Every 30 minutes ) SYNC_SSH_KEYS_PATH: Final[str] = _get_env( - "SYNC_SSH_KEYS_PATH", f"{ROMM_BASE_PATH}/sync/keys" + "SYNC_SSH_KEYS_PATH", f"{SYNC_BASE_PATH}/keys" ) SYNC_SSH_KNOWN_HOSTS_PATH: Final[str] = _get_env( - "SYNC_SSH_KNOWN_HOSTS_PATH", f"{ROMM_BASE_PATH}/sync/known_hosts" + "SYNC_SSH_KNOWN_HOSTS_PATH", f"{SYNC_BASE_PATH}/known_hosts" ) # EMULATION diff --git a/backend/config/config_manager.py b/backend/config/config_manager.py index 0a49b5b8d..9d6400d85 100644 --- a/backend/config/config_manager.py +++ b/backend/config/config_manager.py @@ -647,15 +647,15 @@ class ConfigManager: log.critical("Invalid config.yml: scan.media must be a list") sys.exit(3) - # Drop unknown media types rather than exiting — a newer release may - # ship sample configs referencing media types this version doesn't know. + # Drop unknown media types rather than exiting, since a newer release + # may ship sample configs referencing media types this version doesn't know. unknown_media = [ m for m in self.config.SCAN_MEDIA if m not in MetadataMediaType ] if unknown_media: log.warning( f"Ignoring unknown values in scan.media: {unknown_media}. " - "These may be from a newer RomM version — update to use them." + "These may be from a newer RomM version; update to use them." ) self.config.SCAN_MEDIA = [ m for m in self.config.SCAN_MEDIA if m in MetadataMediaType diff --git a/backend/endpoints/sockets/netplay.py b/backend/endpoints/sockets/netplay.py index 2bed17e88..24ed05113 100644 --- a/backend/endpoints/sockets/netplay.py +++ b/backend/endpoints/sockets/netplay.py @@ -172,7 +172,7 @@ async def webrtc_signal(sid: str, data: WebRTCSignalData): ) else: if not target: - return # drop message—no recipient + return # drop message, no recipient await netplay_socket_handler.socket_server.emit( "webrtc-signal", { diff --git a/backend/handler/database/roms_handler.py b/backend/handler/database/roms_handler.py index 67df73be5..302ed9b20 100644 --- a/backend/handler/database/roms_handler.py +++ b/backend/handler/database/roms_handler.py @@ -931,8 +931,8 @@ class DBRomsHandler(DBBaseHandler): """Retrieve a dictionary of roms by their filesystem names. Eager-loads only `platform` (used downstream by the scan loop via - `rom.platform_slug` / `rom.platform.fs_slug`) — deliberately - avoiding `with_details`, whose full relationship eager-load is + `rom.platform_slug` / `rom.platform.fs_slug`). This deliberately + avoids `with_details`, whose full relationship eager-load is wasted work for the scan-skip decision on large platforms. """ roms = ( diff --git a/backend/handler/filesystem/assets_handler.py b/backend/handler/filesystem/assets_handler.py index 6e5c880d8..bd08917b0 100644 --- a/backend/handler/filesystem/assets_handler.py +++ b/backend/handler/filesystem/assets_handler.py @@ -24,7 +24,7 @@ SAFE_IMAGE_MIME_TYPES: Final[dict[str, str]] = { # libmagic loads its database on construction (~few MB read from disk), so we # share a single Magic instance across requests. The underlying magic_t handle -# is not thread-safe, so guard from_buffer with a lock — endpoints that call +# is not thread-safe, so guard from_buffer with a lock. Endpoints that call # this validator may execute in worker threads under sync routes. _MIME_DETECTOR = magic.Magic(mime=True) _MIME_DETECTOR_LOCK = threading.Lock() diff --git a/backend/handler/filesystem/resources_handler.py b/backend/handler/filesystem/resources_handler.py index 680b6c279..f3e1f5c79 100644 --- a/backend/handler/filesystem/resources_handler.py +++ b/backend/handler/filesystem/resources_handler.py @@ -26,8 +26,8 @@ def _resolve_local_file_uri(uri: str) -> Path | None: """Resolve a local-file URI to an absolute Path, or None if unsafe/unknown. `file://` resolves under the ROM library root. `launchbox-file://` resolves - under the LaunchBox data root — LaunchBox metadata produces paths relative - to `/romm/launchbox`, which is not the same as the library root. + under the LaunchBox data root, since LaunchBox metadata produces paths + relative to `/romm/launchbox`, which is not the same as the library root. """ from handler.filesystem import fs_launchbox_handler, fs_rom_handler diff --git a/backend/handler/metadata/launchbox_handler/remote_source.py b/backend/handler/metadata/launchbox_handler/remote_source.py index 3952cdca9..af5a8190a 100644 --- a/backend/handler/metadata/launchbox_handler/remote_source.py +++ b/backend/handler/metadata/launchbox_handler/remote_source.py @@ -40,7 +40,7 @@ class RemoteSource: if not platform_name: return None - file_name_clean = (file_name or "").strip() + file_name_clean = file_name.strip() if not file_name_clean: return None @@ -78,11 +78,11 @@ class RemoteSource: async def get_mame_entry(self, file_name: str) -> dict | None: """Resolve a MAME arcade filename to its LaunchBox MAME entry. - LaunchBox's Mame.xml indexes `` records by `` — the + LaunchBox's Mame.xml indexes `` records by ``, the MAME short name without an extension (e.g. `wrlok_l3` for `wrlok_l3.zip`). - The entry carries `` — the full title to search for in Metadata.xml. + The entry carries ``, the full title to search for in Metadata.xml. """ - file_name_clean = (file_name or "").strip() + file_name_clean = file_name.strip() if not file_name_clean: return None diff --git a/backend/handler/metadata/libretro_handler.py b/backend/handler/metadata/libretro_handler.py index 591576125..7ee3c51bf 100644 --- a/backend/handler/metadata/libretro_handler.py +++ b/backend/handler/metadata/libretro_handler.py @@ -140,7 +140,7 @@ class LibretroHandler(MetadataHandler): matching MetadataMediaType (SCREENSHOT / TITLE_SCREEN / LOGO) is in SCAN_MEDIA, and appends any matches to `url_screenshots` so the scan_handler artwork loop picks them up. `name` is deliberately - omitted — libretro artwork filenames aren't proper game names. + omitted, since libretro artwork filenames aren't proper game names. """ platform = self.get_platform(platform_slug) if not platform or not platform["libretro_slug"]: diff --git a/backend/handler/metadata/tgdb_handler.py b/backend/handler/metadata/tgdb_handler.py index 4e3abdaca..6ed96d6f0 100644 --- a/backend/handler/metadata/tgdb_handler.py +++ b/backend/handler/metadata/tgdb_handler.py @@ -116,7 +116,7 @@ TGDB_PLATFORM_LIST: dict[UPS, SlugToTGDBId] = { "media_medium": "Cassette tape, floppy disk (optional), ROM cartridge (optional)", "cpu": "MOS Technology 6502A with 2/1 MHz", "memory": "32 kB RAM, 32 kB ROM", - "graphics": "160x256 (4 or 16 colours), 320x256 (2 or 4 colours), 640x256 (2 colours), 320x200 (2 colours — spaced display with two blank horizontal lines following every 8 pixel lines), 640x200 (2 colours — spaced display)", + "graphics": "160x256 (4 or 16 colours), 320x256 (2 or 4 colours), 640x256 (2 colours), 320x200 (2 colours, spaced display with two blank horizontal lines following every 8 pixel lines), 640x200 (2 colours, spaced display)", "sound": "1 channel of sound, 7 octaves; built-in speaker", "display": "RF modulator, composite video, RGB monitor output", "max_controllers": "-", @@ -285,7 +285,7 @@ TGDB_PLATFORM_LIST: dict[UPS, SlugToTGDBId] = { "sound": "Television Interface Adaptor", "display": None, "max_controllers": "2", - "summary": "The Atari 2600 is a video game console released in October 1977 by Atari, Inc. It is credited with popularizing the use of microprocessor-based hardware and cartridges containing game code, instead of having non-microprocessor dedicated hardware with all games built in. The first game console to use this format was the Fairchild Channel F; however, the Atari 2600 receives credit for making the plug-in concept popular among the game-playing public.The console was originally sold as the Atari VCS, for Video Computer System. Following the release of the Atari 5200, in 1982, the VCS was renamed 'Atari 2600', after the unit's Atari part number, CX2600. The 2600 was typically bundled with two joystick controllers, a conjoined pair of paddle controllers, and a cartridge game—initially Combat and later Pac-Man.The Atari 2600 was wildly successful, and during much of the 1980s, 'Atari' was a synonym for this model in mainstream media and, by extension, for video games in general.", + "summary": "The Atari 2600 is a video game console released in October 1977 by Atari, Inc. It is credited with popularizing the use of microprocessor-based hardware and cartridges containing game code, instead of having non-microprocessor dedicated hardware with all games built in. The first game console to use this format was the Fairchild Channel F; however, the Atari 2600 receives credit for making the plug-in concept popular among the game-playing public.The console was originally sold as the Atari VCS, for Video Computer System. Following the release of the Atari 5200, in 1982, the VCS was renamed 'Atari 2600', after the unit's Atari part number, CX2600. The 2600 was typically bundled with two joystick controllers, a conjoined pair of paddle controllers, and a cartridge game, initially Combat and later Pac-Man.The Atari 2600 was wildly successful, and during much of the 1980s, 'Atari' was a synonym for this model in mainstream media and, by extension, for video games in general.", "url_logo": "https://cdn.thegamesdb.net/images/original/platform/boxart/22-1.jpg", }, UPS.ATARI5200: { @@ -585,7 +585,7 @@ TGDB_PLATFORM_LIST: dict[UPS, SlugToTGDBId] = { "sound": "3 x square, 1 x noise, mono.", "display": None, "max_controllers": None, - "summary": "The VIC-20 is an 8-bit home computer which was sold by Commodore Business Machines. The VIC-20 was announced in 1980, roughly three years after Commodore's first personal computer, the PET. The VIC-20 was the first computer of any description to sell one million units. As for commercial software offerings, an estimated 300 titles were available on cartridge, and another 500+ titles were available on tape. By comparison, the Atari 2600—the most popular of the video game consoles at the time—had a library of about 900 titles near the end of its production life (although many titles were extremely similar). Most cartridge games were ready to play as soon as the VIC-20 was turned on, as opposed to games on tape which required a time-consuming loading process. Titles on cartridge included Gorf, Cosmic Cruncher, Sargon II Chess, and many others. A handful of disk applications were released for the VIC-20.", + "summary": "The VIC-20 is an 8-bit home computer which was sold by Commodore Business Machines. The VIC-20 was announced in 1980, roughly three years after Commodore's first personal computer, the PET. The VIC-20 was the first computer of any description to sell one million units. As for commercial software offerings, an estimated 300 titles were available on cartridge, and another 500+ titles were available on tape. By comparison, the Atari 2600, the most popular of the video game consoles at the time, had a library of about 900 titles near the end of its production life (although many titles were extremely similar). Most cartridge games were ready to play as soon as the VIC-20 was turned on, as opposed to games on tape which required a time-consuming loading process. Titles on cartridge included Gorf, Cosmic Cruncher, Sargon II Chess, and many others. A handful of disk applications were released for the VIC-20.", "url_logo": "https://cdn.thegamesdb.net/images/original/platform/boxart/4945-1.jpg", }, UPS.DIDJ: { @@ -975,7 +975,7 @@ TGDB_PLATFORM_LIST: dict[UPS, SlugToTGDBId] = { "sound": None, "display": None, "max_controllers": "2", - "summary": "The Magnavox Odyssey is the first commercial home video game console. It was developed by a small team led by Ralph H. Baer at Sanders Associates and released by Magnavox in the United States in September 1972 and overseas the following year. The Odyssey consists of a white, black, and brown box which connects to a television set and two rectangular controllers attached by wires. It is capable of displaying three square dots on the screen in monochrome black and white, with different behavior of the dots depending on the game played, and has no sound capabilities. Players place plastic overlays on the screen to create visuals, and the one or two players for each game control their dots with the three knobs and one button on the controller in accordance with the rules given for the game. The Odyssey console came packaged with dice, paper money, and other board game paraphernalia to go along with the games, and a peripheral controller—the first video game light gun—was sold separately.The idea for a video game console was thought up by Baer in August 1966, and over the next three years he, along with Bill Harrison and Bill Rusch, created seven successive prototype consoles. The seventh, known as the Brown Box, was shown to several manufacturers before Magnavox agreed to produce it in January 1971. After releasing the console in September 1972 through their dealerships, Magnavox sold between 69,000 and 100,000 units by the end of the year, and 350,000 by the time the console was discontinued in 1975. The console spawned the Magnavox Odyssey series of dedicated consoles, as well as the 1978 Magnavox Odyssey². One of the 28 games made for the system, a ping pong game, was an inspiration for Atari's successful Pong arcade game, in turn driving sales of the console. Baer's patents for the console and the games, including what was termed by a judge as 'the pioneering patent of the video game art', formed the basis of a series of lawsuits over 20 years, earning Sanders and Magnavox over US$100 million. The release of the Odyssey marked the end of the early history of video games, and the rise of the commercial video game industry along with the start of the first generation of video game consoles.", + "summary": "The Magnavox Odyssey is the first commercial home video game console. It was developed by a small team led by Ralph H. Baer at Sanders Associates and released by Magnavox in the United States in September 1972 and overseas the following year. The Odyssey consists of a white, black, and brown box which connects to a television set and two rectangular controllers attached by wires. It is capable of displaying three square dots on the screen in monochrome black and white, with different behavior of the dots depending on the game played, and has no sound capabilities. Players place plastic overlays on the screen to create visuals, and the one or two players for each game control their dots with the three knobs and one button on the controller in accordance with the rules given for the game. The Odyssey console came packaged with dice, paper money, and other board game paraphernalia to go along with the games, and a peripheral controller, the first video game light gun, was sold separately.The idea for a video game console was thought up by Baer in August 1966, and over the next three years he, along with Bill Harrison and Bill Rusch, created seven successive prototype consoles. The seventh, known as the Brown Box, was shown to several manufacturers before Magnavox agreed to produce it in January 1971. After releasing the console in September 1972 through their dealerships, Magnavox sold between 69,000 and 100,000 units by the end of the year, and 350,000 by the time the console was discontinued in 1975. The console spawned the Magnavox Odyssey series of dedicated consoles, as well as the 1978 Magnavox Odyssey². One of the 28 games made for the system, a ping pong game, was an inspiration for Atari's successful Pong arcade game, in turn driving sales of the console. Baer's patents for the console and the games, including what was termed by a judge as 'the pioneering patent of the video game art', formed the basis of a series of lawsuits over 20 years, earning Sanders and Magnavox over US$100 million. The release of the Odyssey marked the end of the early history of video games, and the rise of the commercial video game industry along with the start of the first generation of video game consoles.", "url_logo": None, }, UPS.ODYSSEY_2: { @@ -1275,7 +1275,7 @@ TGDB_PLATFORM_LIST: dict[UPS, SlugToTGDBId] = { "sound": "2 square wave generators, 1 PCM 4-bit wave sample channel", "display": "160 x 144", "max_controllers": "1", - "summary": "The Game Boy, is an 8-bit handheld video game device developed and manufactured by Nintendo. It was released in Japan on April 21, 1989, in North America in August 1989, and in Europe on September 28, 1990. It is the first handheld console in the Game Boy line, and was created by Gunpei Yokoi and Nintendo Research & Development 1—the same staff who had designed the Game & Watch series as well as several popular games for the Nintendo Entertainment System.", + "summary": "The Game Boy, is an 8-bit handheld video game device developed and manufactured by Nintendo. It was released in Japan on April 21, 1989, in North America in August 1989, and in Europe on September 28, 1990. It is the first handheld console in the Game Boy line, and was created by Gunpei Yokoi and Nintendo Research & Development 1, the same staff who had designed the Game & Watch series as well as several popular games for the Nintendo Entertainment System.", "url_logo": None, }, UPS.GBA: { diff --git a/backend/sync_watcher.py b/backend/sync_watcher.py index 827cb7cf6..7b3fb60cb 100644 --- a/backend/sync_watcher.py +++ b/backend/sync_watcher.py @@ -46,7 +46,7 @@ Change = tuple[str, str] def _extract_device_and_platform(path: str) -> tuple[str, str, str] | None: """Extract device_id, platform_slug, and filename from a sync incoming path. - Expected path format: {SYNC_BASE_PATH}/{device_id}/incoming/{platform_slug}/filename.ext + Expected path format: {ROMM_BASE_PATH}/sync/{device_id}/incoming/{platform_slug}/filename.ext """ try: rel_path = os.path.relpath(path, start=str(fs_sync_handler.base_path)) diff --git a/backend/tests/config/fixtures/config/malformed_config.yml b/backend/tests/config/fixtures/config/malformed_config.yml index f66ab5452..9828c7206 100644 --- a/backend/tests/config/fixtures/config/malformed_config.yml +++ b/backend/tests/config/fixtures/config/malformed_config.yml @@ -1,4 +1,4 @@ -# Intentionally malformed YAML — used to verify the loader falls back to +# Intentionally malformed YAML, used to verify the loader falls back to # defaults rather than crashing on a parse error. scan: diff --git a/backend/tests/endpoints/sockets/test_scan.py b/backend/tests/endpoints/sockets/test_scan.py index f75b5253a..abac05e2a 100644 --- a/backend/tests/endpoints/sockets/test_scan.py +++ b/backend/tests/endpoints/sockets/test_scan.py @@ -180,7 +180,7 @@ class TestShouldScanRom: assert result is True def test_no_scan_when_rom_id_not_in_list(self, rom: Rom): - """When roms_ids is non-empty, scan is scoped — roms outside the list are skipped for every scan type""" + """When roms_ids is non-empty, scan is scoped: roms outside the list are skipped for every scan type""" rom.id = 4 rom.igdb_id = None rom.moby_id = None diff --git a/backend/tests/endpoints/test_collection.py b/backend/tests/endpoints/test_collection.py index c632e126f..23d38dffc 100644 --- a/backend/tests/endpoints/test_collection.py +++ b/backend/tests/endpoints/test_collection.py @@ -70,7 +70,7 @@ def second_rom(admin_user: User, platform: Platform) -> Rom: @pytest.fixture def other_user_token(editor_user: User) -> str: - """Access token for a second user — used to test ownership checks.""" + """Access token for a second user, used to test ownership checks.""" return oauth_handler.create_access_token( data={ "sub": editor_user.username, @@ -238,7 +238,7 @@ class TestDeleteCollection: # --------------------------------------------------------------------------- -# POST /collections/{id}/roms — atomic add +# POST /collections/{id}/roms (atomic add) # --------------------------------------------------------------------------- @@ -385,7 +385,7 @@ class TestAddRomsToCollection: # --------------------------------------------------------------------------- -# DELETE /collections/{id}/roms — atomic remove +# DELETE /collections/{id}/roms (atomic remove) # --------------------------------------------------------------------------- @@ -524,7 +524,7 @@ class TestAtomicBehavior: ): """ Simulates the corrected behavior: two separate add calls, each with a - single ROM, should result in both ROMs being present — even if they + single ROM, should result in both ROMs being present, even if they arrive close together. This would previously fail under the full-replace approach when requests arrived out of order. """ @@ -552,8 +552,8 @@ class TestAtomicBehavior: second_rom: Rom, ): """ - Add both ROMs, remove one, add it back — final state should reflect - only the last operation per ROM. + Add both ROMs, remove one, add it back. The final state should + reflect only the last operation per ROM. """ client.post( f"/api/collections/{collection.id}/roms", diff --git a/backend/tests/handler/filesystem/test_base_handler.py b/backend/tests/handler/filesystem/test_base_handler.py index 3fe7efbd7..68f585aca 100644 --- a/backend/tests/handler/filesystem/test_base_handler.py +++ b/backend/tests/handler/filesystem/test_base_handler.py @@ -193,7 +193,7 @@ class TestFSHandler: assert "game.nds.hash.txt" not in result assert "game.nds.enc.hash.txt" not in result - # "readme.txt" does NOT end in "hash.txt" — should remain + # "readme.txt" does NOT end in "hash.txt", so it should remain assert "readme.txt" in result assert "game.nds" in result assert "game.rom" in result diff --git a/backend/tests/handler/metadata/test_launchbox_handler.py b/backend/tests/handler/metadata/test_launchbox_handler.py index dfaf5408d..51ee66152 100644 --- a/backend/tests/handler/metadata/test_launchbox_handler.py +++ b/backend/tests/handler/metadata/test_launchbox_handler.py @@ -2,11 +2,11 @@ Tests for the LaunchBox metadata handler. Covers: - - utils.py — pure utility functions - - platforms.py — platform slug resolution - - local_source.py — LocalSource (local XML parsing + Redis index cache) - - remote_source.py — RemoteSource (Redis metadata lookups) - - handler.py — LaunchboxHandler orchestration + - utils.py: pure utility functions + - platforms.py: platform slug resolution + - local_source.py: LocalSource (local XML parsing + Redis index cache) + - remote_source.py: RemoteSource (Redis metadata lookups) + - handler.py: LaunchboxHandler orchestration """ import json diff --git a/backend/tests/handler/metadata/test_libretro_handler.py b/backend/tests/handler/metadata/test_libretro_handler.py index 8905a75a4..77b40ddc1 100644 --- a/backend/tests/handler/metadata/test_libretro_handler.py +++ b/backend/tests/handler/metadata/test_libretro_handler.py @@ -77,8 +77,8 @@ def test_platform_list_uses_ups_keys(): def test_find_matching_art_exact_case_insensitive(handler: LibretroHandler): - # The match should prefer the exact case-insensitive filename — region tag - # included — so a PAL ROM lands on the (Europe) artwork. + # The match should prefer the exact case-insensitive filename (region tag + # included), so a PAL ROM lands on the (Europe) artwork. result = handler._find_matching_art( "Castlevania - Symphony of the Night (Europe).iso", PSX_LISTING ) @@ -101,7 +101,7 @@ def test_find_matching_art_ampersand_normalized(handler: LibretroHandler): def test_find_matching_art_fuzzy_fallback(handler: LibretroHandler): - # No exact match — ROM has an extra `(Rev 1)` tag that libretro doesn't + # No exact match, since the ROM has an extra `(Rev 1)` tag that libretro doesn't # index. Fuzzy fallback strips tags from both sides; the Europe variant # is the first tag-stripped candidate and wins. result = handler._find_matching_art( @@ -289,5 +289,5 @@ def test_art_type_values(): def test_is_enabled_always_true(): - # No API key required — public server. + # No API key required; this is a public server. assert LibretroHandler.is_enabled() is True diff --git a/docker/Dockerfile b/docker/Dockerfile index cda976526..1571e0a46 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -218,7 +218,7 @@ ENV PYTHONUNBUFFERED=1 ENV PYTHONPATH=/backend # Declare the supported volumes -VOLUME ["/romm/resources", "/romm/library", "/romm/assets", "/romm/config", "/redis-data"] +VOLUME ["/romm/resources", "/romm/library", "/romm/assets", "/romm/config", "/romm/sync", "/redis-data"] # Expose non-privileged ports EXPOSE 8080 6379/tcp diff --git a/docker/init_scripts/init b/docker/init_scripts/init index 6a8b0bf79..39ee0f2ac 100755 --- a/docker/init_scripts/init +++ b/docker/init_scripts/init @@ -88,7 +88,7 @@ wait_for_gunicorn_socket() { fi } -# Function that runs our main process and creates a corresponding PID file +# Runs our main process and creates a corresponding PID file start_bin_gunicorn() { # cleanup potentially leftover socket rm /tmp/gunicorn.sock -f @@ -248,16 +248,18 @@ start_bin_watcher() { start_bin_sync_watcher() { info_log "Starting sync folder watcher" + sync_base_path="${ROMM_BASE_PATH:-/romm}/sync" + mkdir -p "${sync_base_path}" if [[ ${OTEL_SDK_DISABLED:-false} == "true" ]]; then watchfiles \ --target-type command \ "python3 sync_watcher.py" \ - /romm/sync & + "${sync_base_path}" & else watchfiles \ --target-type command \ "opentelemetry-instrument --service_name '${OTEL_SERVICE_NAME_PREFIX-}sync_watcher' python3 sync_watcher.py" \ - /romm/sync & + "${sync_base_path}" & fi SYNC_WATCHER_PID=$! echo "${SYNC_WATCHER_PID}" >/tmp/sync_watcher.pid diff --git a/docs/BACKEND_ARCHITECTURE.md b/docs/BACKEND_ARCHITECTURE.md index cc3c43ffb..6935d375c 100644 --- a/docs/BACKEND_ARCHITECTURE.md +++ b/docs/BACKEND_ARCHITECTURE.md @@ -43,13 +43,13 @@ Comprehensive documentation of the RomM backend: a FastAPI-based server powering RomM's backend is responsible for: -- **Library scanning** — detecting platforms and ROMs from the filesystem -- **Metadata enrichment** — pulling game info from 10+ external providers -- **User management** — roles, authentication, per-user game tracking -- **Asset management** — saves, save states, screenshots, firmware/BIOS -- **Device sync** — cross-device save synchronization -- **Netplay** — real-time multiplayer room coordination -- **Feed generation** — Tinfoil, WebRcade, PKGi, and other custom formats +- **Library scanning**: detecting platforms and ROMs from the filesystem +- **Metadata enrichment**: pulling game info from 10+ external providers +- **User management**: roles, authentication, per-user game tracking +- **Asset management**: saves, save states, screenshots, firmware/BIOS +- **Device sync**: cross-device save synchronization +- **Netplay**: real-time multiplayer room coordination +- **Feed generation**: Tinfoil, WebRcade, PKGi, and other custom formats --- @@ -378,13 +378,13 @@ Request → CORS → CSRF → Authentication → Session (Redis) → Context Va Response ← CORS ← CSRF ← Authentication ← Session (Redis) ← Context Vars ← Endpoint ``` -| Layer | Middleware | Purpose | -| ----- | -------------------------- | -------------------------------------------------- | -| 1 | `CORSMiddleware` | Allow cross-origin requests (all origins) | -| 2 | `CSRFMiddleware` | Token-based CSRF protection (cookie + header) | -| 3 | `AuthenticationMiddleware` | `HybridAuthBackend` — Basic, Bearer, Session, OIDC | -| 4 | `RedisSessionMiddleware` | Cookie-based sessions stored in Redis | -| 5 | `set_context_middleware` | Inject aiohttp/httpx clients into context vars | +| Layer | Middleware | Purpose | +| ----- | -------------------------- | ------------------------------------------------- | +| 1 | `CORSMiddleware` | Allow cross-origin requests (all origins) | +| 2 | `CSRFMiddleware` | Token-based CSRF protection (cookie + header) | +| 3 | `AuthenticationMiddleware` | `HybridAuthBackend`: Basic, Bearer, Session, OIDC | +| 4 | `RedisSessionMiddleware` | Cookie-based sessions stored in Redis | +| 5 | `set_context_middleware` | Inject aiohttp/httpx clients into context vars | ### Request Flow @@ -547,7 +547,7 @@ Constants: `FILE_NAME_MAX_LENGTH=450`, `FILE_PATH_MAX_LENGTH=1000`, `FILE_EXTENS #### ROMs -**Table:** `roms` — the central entity +**Table:** `roms` (the central entity) | Column Group | Columns | Notes | | --------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------- | @@ -585,7 +585,7 @@ Tracks individual files within a ROM (archives can contain multiple files). #### ROM Metadata (Aggregated) -**Table:** `roms_metadata` — aggregated metadata from all providers +**Table:** `roms_metadata` (aggregated metadata from all providers) | Column | Type | | -------------------- | --------------------------- | @@ -604,7 +604,7 @@ Tracks individual files within a ROM (archives can contain multiple files). #### ROM User Data -**Table:** `rom_user` — per-user, per-ROM tracking +**Table:** `rom_user` (per-user, per-ROM tracking) | Column | Type | Notes | | -------------------- | ------------ | --------------------------------------------------------------------- | @@ -638,7 +638,7 @@ Tracks individual files within a ROM (archives can contain multiple files). #### Collections -**Table:** `collections` — manually curated ROM lists +**Table:** `collections` (manually curated ROM lists) | Column | Type | Notes | | ----------------------------- | ----------- | --------- | @@ -652,7 +652,7 @@ Tracks individual files within a ROM (archives can contain multiple files). Linked to ROMs via `collections_roms` join table (M:M). -**Table:** `smart_collections` — dynamic, filter-based +**Table:** `smart_collections` (dynamic, filter-based) | Column | Type | Notes | | ----------------- | ------- | ----------------------- | @@ -660,7 +660,7 @@ Linked to ROMs via `collections_roms` join table (M:M). | `rom_ids` | JSON | Cached matching ROM IDs | | `rom_count` | Integer | Cached count | -**View:** `virtual_collections` — database view, read-only, excluded from migrations. +**View:** `virtual_collections` (database view, read-only, excluded from migrations). --- @@ -672,7 +672,7 @@ All three share a similar structure: | ------------- | ---------------------------------- | ------------------- | | `saves` | `emulator`, `slot`, `content_hash` | Device sync support | | `states` | `emulator` | Save states | -| `screenshots` | — | In-game captures | +| `screenshots` | | In-game captures | Common columns: `id`, `rom_id` (FK), `user_id` (FK), `file_name`, `file_path`, `file_size_bytes`, `missing_from_fs` @@ -693,7 +693,7 @@ Saves additionally link to `device_save_sync` for cross-device tracking. | `sync_enabled` | Boolean | | | `last_seen` | Timestamp | | -**Table:** `device_save_sync` — tracks per-device, per-save sync state +**Table:** `device_save_sync` (tracks per-device, per-save sync state) | Column | Type | | ----------------------- | ------------ | @@ -705,7 +705,7 @@ Saves additionally link to `device_save_sync` for cross-device tracking. #### Client Tokens -**Table:** `client_tokens` — long-lived API tokens +**Table:** `client_tokens` (long-lived API tokens) | Column | Type | Notes | | -------------- | ------------ | ---------------------------- | @@ -1025,15 +1025,15 @@ The codebase exposes roughly **175 HTTP routes** and **11 WebSocket handlers** a ### Scope Definitions ```text -me.read / me.write — Own profile -roms.read / roms.write — ROM data -platforms.read / platforms.write — Platform data -assets.read / assets.write — Saves, states, screenshots -devices.read / devices.write — Device management -firmware.read / firmware.write — BIOS files -collections.read / collections.write — Collections -users.read / users.write — User management (admin) -tasks.run — Task execution +me.read / me.write : Own profile +roms.read / roms.write : ROM data +platforms.read / platforms.write : Platform data +assets.read / assets.write : Saves, states, screenshots +devices.read / devices.write : Device management +firmware.read / firmware.write : BIOS files +collections.read / collections.write : Collections +users.read / users.write : User management (admin) +tasks.run : Task execution ``` ### CSRF Protection @@ -1056,7 +1056,7 @@ tasks.run — Task execution ### 8.1 Scan Handler (`handler/scan_handler.py`) -The core of RomM — orchestrates library scanning and metadata enrichment. +The core of RomM. Orchestrates library scanning and metadata enrichment. **Scan Types:** @@ -1185,7 +1185,7 @@ Tracks per-user playtime events ingested from clients (web player, console mode, ### 8.7 Device Sync Sessions -Coordinates save/state synchronization between devices using three sync modes (`API`, `FILE_TRANSFER`, `PUSH_PULL`). `SyncSession` tracks the lifecycle of a push/pull operation (including optional SSH-based file transfer — see `SYNC_SSH_*` env vars). Endpoints live in `endpoints/sync.py`; state is stored in the `sync_sessions` table. +Coordinates save/state synchronization between devices using three sync modes (`API`, `FILE_TRANSFER`, `PUSH_PULL`). `SyncSession` tracks the lifecycle of a push/pull operation (including optional SSH-based file transfer; see `SYNC_SSH_*` env vars). Endpoints live in `endpoints/sync.py`; state is stored in the `sync_sessions` table. ### 8.8 Socket Handler (`handler/socket_handler.py`) @@ -1302,7 +1302,7 @@ Client ←──Socket.IO──→ FastAPI (python-socketio) ←──Redis P | ------------------- | ------------------ | --------------------------- | | `scan:update_stats` | `ScanStats` object | Each ROM/platform processed | | `scan:log` | Log message | Scan log entries | -| `scan:stop` | — | Scan completed or cancelled | +| `scan:stop` | | Scan completed or cancelled | ### Netplay (`/netplay`) @@ -1476,10 +1476,10 @@ Falls back to `FakeRedis` in test mode. | Variable | Default | Description | | ---------------- | --------- | ----------------------------------- | | `ROMM_DB_DRIVER` | `mariadb` | `mariadb`, `mysql`, or `postgresql` | -| `DB_HOST` | — | Database host | +| `DB_HOST` | | Database host | | `DB_PORT` | `3306` | Database port | -| `DB_USER` | — | Database user | -| `DB_PASSWD` | — | Database password | +| `DB_USER` | | Database user | +| `DB_PASSWD` | | Database password | | `DB_NAME` | `romm` | Database name | #### Redis @@ -1488,8 +1488,8 @@ Falls back to `FakeRedis` in test mode. | ---------------- | ----------- | --------------------- | | `REDIS_HOST` | `127.0.0.1` | Redis host | | `REDIS_PORT` | `6379` | Redis port | -| `REDIS_USERNAME` | — | Redis username (ACL) | -| `REDIS_PASSWORD` | — | Redis password | +| `REDIS_USERNAME` | | Redis username (ACL) | +| `REDIS_PASSWORD` | | Redis password | | `REDIS_DB` | `0` | Redis database number | | `REDIS_SSL` | `false` | Enable SSL | @@ -1497,7 +1497,7 @@ Falls back to `FakeRedis` in test mode. | Variable | Default | Description | | ------------------------------------ | --------- | ------------------------------------- | -| `ROMM_AUTH_SECRET_KEY` | — | **Required.** JWT/session signing key | +| `ROMM_AUTH_SECRET_KEY` | | **Required.** JWT/session signing key | | `OAUTH_ACCESS_TOKEN_EXPIRE_SECONDS` | `1800` | 30 minutes | | `OAUTH_REFRESH_TOKEN_EXPIRE_SECONDS` | `604800` | 7 days | | `SESSION_MAX_AGE_SECONDS` | `1209600` | 14 days | @@ -1511,16 +1511,16 @@ Falls back to `FakeRedis` in test mode. | Variable | Default | Description | | ------------------------------- | -------------------- | ------------------------------- | | `OIDC_ENABLED` | `false` | Enable OpenID Connect | -| `OIDC_PROVIDER` | — | Provider URL | -| `OIDC_CLIENT_ID` | — | Client ID | -| `OIDC_CLIENT_SECRET` | — | Client secret | -| `OIDC_REDIRECT_URI` | — | Redirect URI | +| `OIDC_PROVIDER` | | Provider URL | +| `OIDC_CLIENT_ID` | | Client ID | +| `OIDC_CLIENT_SECRET` | | Client secret | +| `OIDC_REDIRECT_URI` | | Redirect URI | | `OIDC_USERNAME_ATTRIBUTE` | `preferred_username` | Username claim | -| `OIDC_CLAIM_ROLES` | — | Roles claim name | -| `OIDC_ROLE_VIEWER/EDITOR/ADMIN` | — | Role mappings | -| `OIDC_TLS_CACERTFILE` | — | Custom CA bundle for OIDC calls | +| `OIDC_CLAIM_ROLES` | | Roles claim name | +| `OIDC_ROLE_VIEWER/EDITOR/ADMIN` | | Role mappings | +| `OIDC_TLS_CACERTFILE` | | Custom CA bundle for OIDC calls | | `OIDC_RP_INITIATED_LOGOUT` | `false` | Send logout to OIDC provider | -| `OIDC_END_SESSION_ENDPOINT` | — | End-session URL override | +| `OIDC_END_SESSION_ENDPOINT` | | End-session URL override | #### API Keys @@ -1551,25 +1551,25 @@ Falls back to `FakeRedis` in test mode. | -------------------------------------- | ----------- | ------------------------------- | | `SCAN_TIMEOUT` | `14400` | 4-hour scan timeout | | `SCAN_WORKERS` | `1` | Concurrent scan workers | -| `TASK_TIMEOUT` | — | RQ job timeout for manual tasks | -| `TASK_RESULT_TTL` | — | How long to keep job results | +| `TASK_TIMEOUT` | | RQ job timeout for manual tasks | +| `TASK_RESULT_TTL` | | How long to keep job results | | `ENABLE_SCHEDULED_RESCAN` | `false` | Auto library rescan | | `SCHEDULED_RESCAN_CRON` | `0 3 * * *` | Rescan schedule | | `ENABLE_RESCAN_ON_FILESYSTEM_CHANGE` | `false` | Watch for file changes | | `RESCAN_ON_FILESYSTEM_CHANGE_DELAY` | `5` | Debounce delay (minutes) | -| `SEVEN_ZIP_TIMEOUT` | — | Timeout for 7-Zip extraction | -| `REFRESH_RETROACHIEVEMENTS_CACHE_DAYS` | — | RA cache TTL (days) | +| `SEVEN_ZIP_TIMEOUT` | | Timeout for 7-Zip extraction | +| `REFRESH_RETROACHIEVEMENTS_CACHE_DAYS` | | RA cache TTL (days) | #### Device Sync | Variable | Default | Description | | ---------------------------- | ------- | ------------------------------- | | `ENABLE_SYNC_FOLDER_WATCHER` | `false` | Watch sync folder for new saves | -| `SYNC_FOLDER_SCAN_DELAY` | — | Debounce for sync folder scans | +| `SYNC_FOLDER_SCAN_DELAY` | | Debounce for sync folder scans | | `ENABLE_SYNC_PUSH_PULL` | `false` | Enable scheduled push/pull sync | -| `SYNC_PUSH_PULL_CRON` | — | Cron schedule for push/pull | -| `SYNC_SSH_KEYS_PATH` | — | SSH keys path | -| `SYNC_SSH_KNOWN_HOSTS_PATH` | — | SSH known hosts path | +| `SYNC_PUSH_PULL_CRON` | | Cron schedule for push/pull | +| `SYNC_SSH_KEYS_PATH` | | SSH keys path | +| `SYNC_SSH_KNOWN_HOSTS_PATH` | | SSH known hosts path | ### YAML Configuration (`config.yml`) @@ -1627,12 +1627,12 @@ Managed by `ConfigManager` (singleton pattern) which reads, validates, and write ```text Exception -├── AuthCredentialsException # 401 — Incorrect credentials -├── AuthenticationSchemeException # 401 — Invalid auth scheme -├── UserDisabledException # 401 — Account disabled -├── OAuthCredentialsException # 401 — Invalid OAuth token -├── OIDCDisabledException # 500 — OIDC not configured -├── OIDCNotConfiguredException # 500 — OIDC feature disabled +├── AuthCredentialsException # 401: Incorrect credentials +├── AuthenticationSchemeException # 401: Invalid auth scheme +├── UserDisabledException # 401: Account disabled +├── OAuthCredentialsException # 401: Invalid OAuth token +├── OIDCDisabledException # 500: OIDC not configured +├── OIDCNotConfiguredException # 500: OIDC feature disabled │ ├── PlatformNotFoundInDatabaseException # 404 ├── RomNotFoundInDatabaseException # 404 diff --git a/docs/FRONTEND_ARCHITECTURE.md b/docs/FRONTEND_ARCHITECTURE.md index f4c12406b..698132e59 100644 --- a/docs/FRONTEND_ARCHITECTURE.md +++ b/docs/FRONTEND_ARCHITECTURE.md @@ -323,12 +323,12 @@ index.html ### Plugin Registration Order ```text -1. Vuetify — Material Design components, themes, icons -2. Pinia — State management (with router injection) -3. vue-i18n — Internationalization (17 locales) -4. Mitt — Event emitter (provided as 'emitter') -5. MD Editor — Markdown editor with XSS plugin -6. Vue Router — Navigation with guards +1. Vuetify : Material Design components, themes, icons +2. Pinia : State management (with router injection) +3. vue-i18n : Internationalization (17 locales) +4. Mitt : Event emitter (provided as 'emitter') +5. MD Editor : Markdown editor with XSS plugin +6. Vue Router : Navigation with guards ``` ### Request Lifecycle @@ -864,10 +864,10 @@ All synthesized with sine/noise blend, exponential envelopes, low-pass filter, a `utils/index.ts` provides: -- `getSupportedEJSCores(platform)` — maps platforms to EmulatorJS cores -- `isEJSEmulationSupported(rom)` — checks WebGL + server config -- `isRuffleEmulationSupported(rom)` — checks Flash platform -- `isCDBasedSystem(platform)` — 31 CD-based platforms for animation logic +- `getSupportedEJSCores(platform)`: maps platforms to EmulatorJS cores +- `isEJSEmulationSupported(rom)`: checks WebGL + server config +- `isRuffleEmulationSupported(rom)`: checks Flash platform +- `isCDBasedSystem(platform)`: 31 CD-based platforms for animation logic --- @@ -921,7 +921,7 @@ Vuetify handles theme switching. Additional shared brand colors: `romm-red`, `ro | Code | Language | | ------- | --------------------------- | -| `en_US` | English (US) — default | +| `en_US` | English (US, default) | | `en_GB` | English (UK) | | `fr_FR` | French | | `de_DE` | German | @@ -964,9 +964,9 @@ io({ **Events consumed:** -- `scan:update_stats` — live scan progress (platform/ROM counts) -- `scan:log` — scan log messages -- `scan:stop` — scan completion +- `scan:update_stats`: live scan progress (platform/ROM counts) +- `scan:log`: scan log messages +- `scan:stop`: scan completion **Dev proxy:** Vite proxies `/ws` to backend with WebSocket upgrade support. @@ -1016,34 +1016,34 @@ Request Flow with Cache: **Display:** -- `formatBytes()` — human-readable sizes (B through PB) -- `formatTimestamp()` — locale-aware dates -- `formatRelativeDate()` — relative time strings +- `formatBytes()`: human-readable sizes (B through PB) +- `formatTimestamp()`: locale-aware dates +- `formatRelativeDate()`: relative time strings **Emojis & Localization:** -- `regionToEmoji()` — 50+ region codes → country flags -- `languageToEmoji()` — 40+ language codes → country flags +- `regionToEmoji()`: 50+ region codes → country flags +- `languageToEmoji()`: 40+ language codes → country flags **Emulation Support:** -- `getSupportedEJSCores()` — platform → EmulatorJS core mapping -- `isEJSEmulationSupported()` — WebGL + config check -- `isCDBasedSystem()` — 31 CD-based platforms +- `getSupportedEJSCores()`: platform → EmulatorJS core mapping +- `isEJSEmulationSupported()`: WebGL + config check +- `isCDBasedSystem()`: 31 CD-based platforms **Game Status:** -- `romStatusMap` — 8 statuses with emoji, text, i18n keys +- `romStatusMap`: 8 statuses with emoji, text, i18n keys - Status enum: `unplayed`, `now_playing`, `backlogged`, `paused`, `completed`, `100%`, `retired`, `never_playing` **Layout:** -- `views` — 3 view modes with responsive grid configurations -- `calculateMainLayoutWidth()` — dynamic width based on drawer state +- `views`: 3 view modes with responsive grid configurations +- `calculateMainLayoutWidth()`: dynamic width based on drawer state **Task Display:** -- `convertCronExpression()` — human-readable cron (via cronstrue) +- `convertCronExpression()`: human-readable cron (via cronstrue) - Task status/type maps with colors and icons ### Cover Generation (`utils/covers.ts`) @@ -1075,8 +1075,8 @@ Procedural SVG generation for: 1. Tailwind CSS (`@tailwindcss/vite`) 2. Vue 3 (`@vitejs/plugin-vue`) 3. Vuetify auto-import (`vite-plugin-vuetify`, 57 pre-optimized components) -4. PWA (`vite-plugin-pwa` — service worker, installable) -5. HTTPS (`vite-plugin-mkcert` — optional dev HTTPS) +4. PWA (`vite-plugin-pwa`, service worker, installable) +5. HTTPS (`vite-plugin-mkcert`, optional dev HTTPS) 6. Static copy (ROM patcher JS assets) ### Scripts diff --git a/entrypoint.sh b/entrypoint.sh index 1b192e52a..33e77dc2c 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -80,10 +80,12 @@ watchfiles \ if [[ ${ENABLE_SYNC_FOLDER_WATCHER:-false} == "true" ]]; then echo "Starting sync folder watcher..." + sync_base_path="${ROMM_BASE_PATH:-/romm}/sync" + mkdir -p "${sync_base_path}" watchfiles \ --target-type command \ 'uv run python sync_watcher.py' \ - /app/romm/sync & + "${sync_base_path}" & fi # Start the frontend dev server diff --git a/env.template b/env.template index 74f9bf52b..b6c5b0f80 100644 --- a/env.template +++ b/env.template @@ -88,7 +88,6 @@ ENABLE_SCHEDULED_RETROACHIEVEMENTS_PROGRESS_SYNC=false # Enable scheduled Retro SCHEDULED_RETROACHIEVEMENTS_PROGRESS_SYNC_CRON=0 4 * * * # Cron expression for scheduled RetroAchievements sync # Sync -SYNC_BASE_PATH= # Base folder for sync state (defaults to $ROMM_BASE_PATH/sync) ENABLE_SYNC_FOLDER_WATCHER=false # Watch the sync folder and trigger scans on change SYNC_FOLDER_SCAN_DELAY=2 # Delay in minutes before scanning after a sync folder change ENABLE_SYNC_PUSH_PULL=false # Enable scheduled sync push/pull diff --git a/frontend/src/components/Home/ContinuePlaying.vue b/frontend/src/components/Home/ContinuePlaying.vue index 788932207..8567020c3 100644 --- a/frontend/src/components/Home/ContinuePlaying.vue +++ b/frontend/src/components/Home/ContinuePlaying.vue @@ -63,7 +63,7 @@ function onClosedMenu() { { transitioning: !isVideoPlaying, }" :src="largeCover || fallbackCoverImage" - :aspect-ratio="computedAspectRatio" @click="handleClick" @touchstart="handleTouchStart" @touchend="handleTouchEnd" @@ -428,7 +427,6 @@ onBeforeUnmount(() => { :cover="false" eager :src="smallCover || fallbackCoverImage" - :aspect-ratio="computedAspectRatio" >