Commit Graph

379 Commits

Author SHA1 Message Date
Georges-Antoine Assi
7f0636aed5 Apply suggestion from @greptile-apps[bot]
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2026-07-28 21:26:15 -04:00
Georges-Antoine Assi
48259b3a9e fix(docker): snapshot the internal valkey hourly instead of every few minutes
The keyspace holds the Switch TitleDB and LaunchBox caches, so dump.rdb runs
to hundreds of MB (424MB on a dev instance). Valkey's stock save policy
rewrites all of it every ~5 minutes once 100 keys change, which idle RQ
bookkeeping alone triggers, for gigabytes of disk writes per hour.

Fixes #3980

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-28 18:41:49 -04:00
Ryan McClelland
90d1c72256 feat(tasks): allow orphaned resource cleanup to run on a schedule
Orphaned covers and screenshots left behind by deleted ROMs accumulate
indefinitely, because the only way to reclaim them is to trigger the
cleanup task by hand. On a long-lived instance the resources directory
grows without bound, which is a problem when it shares a filesystem with
the database.

Move the task to `tasks/scheduled/` and turn it into a `PeriodicTask`
with an opt-in cron schedule, defaulting to 5:00 AM so it runs after the
nightly scan and metadata tasks have settled.

`enabled` stays `True` rather than tracking the new env var, because the
run-task endpoint requires both `enabled` and `manual_run`. Gating it
would have silently removed the ability to run the cleanup by hand,
which is how it works today. The cron string is what is opt-in, and
`init()` unschedules when it is unset.

Add the new flag to the init script's scheduler condition, so enabling
only this schedule still starts `rqscheduler`.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 13:53:30 -07:00
Georges-Antoine Assi
f1b49fa9c2 cleanup 2026-07-27 08:22:25 -04:00
Georges-Antoine Assi
98651ecbf8 Fix ROMM_AUTH_SECRET_KEY auto-generation under nounset
The init script runs with `set -o nounset`, so testing `${ROMM_AUTH_SECRET_KEY}`
aborted with "unbound variable" before reaching the generation branch, leaving
the container in a restart loop. This only triggered when the variable was
omitted entirely; shipping it with an empty value took the working path.

Use `${ROMM_AUTH_SECRET_KEY-}` so the unset case is testable, and warn instead
of info since a generated key changes on every restart.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-27 08:07:50 -04:00
Georges-Antoine Assi
5edf6bc4f7 Merge pull request #3892 from Spinnich/fix/asset-cache-headers
fix(nginx): cache only fingerprinted assets, revalidate the rest
2026-07-23 08:17:29 -04:00
Georges-Antoine Assi
c70f7d1df3 cleanup 2026-07-23 08:06:42 -04:00
Georges-Antoine Assi
dfc4f6a6f5 fix(archives): end bsdtar options before the member argument
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-23 07:48:05 -04:00
Spinnich
61c3dd1e4c fix(nginx): cache only fingerprinted assets, revalidate the rest
RomM's nginx served everything under /assets, plus the root favicons and
manifest, with no Cache-Control, so browsers re-fetched or revalidated the
frontend bundle and every cover image on repeat visits.

Only some of these assets are safe to cache long-term, so a blanket immutable
rule is unsafe. Cache by fingerprint instead:

- Content-hashed bundles (index-<hash>.js) and library resources that carry a
  cache-busting query (covers ?ts=, manuals ?v=) -> public, max-age=31536000,
  immutable.
- Query-less library resources (screenshots and RA badges, which reuse stable
  filenames and are overwritten on re-scrape), the bundled EmulatorJS/Ruffle
  runtimes, and other static files under /assets -> public, max-age=3600,
  must-revalidate.
- index.html and the root favicons/manifest/service worker -> no-cache, so a
  new deploy's bundles and any updated runtime are picked up at once.

The resources split is driven by an $is_args map, so a resource is frozen only
while its URL carries a busting query.

Fixes #3890

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-22 22:23:21 +00:00
Georges-Antoine Assi
dc981f51c8 fix(archives): read RAR archives through bsdtar so they can be hashed
The bundled 7zz is built without the RAR codec (unRAR license), so it can
neither list nor extract RAR members. Every content-based match silently
came up empty for .rar: no RetroAchievements hash and no CRC/MD5/SHA-1 for
hash-database providers.

RAR listing and extraction now go through libarchive's bsdtar, added to the
images as libarchive-tools. Listing uses an mtree rewrite (libarchive's only
machine-readable listing) and member names are escaped before being handed
back to bsdtar, which matches them as globs.

Fixes #3884

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-22 10:13:50 -04:00
Georges-Antoine Assi
9488ceba0e Merge pull request #3167 from tmgast/fix/mod-zip-range-requests
feat: Support Range requests for multi-file ROM downloads
2026-07-19 18:32:12 -04:00
Georges-Antoine Assi
168fb2f009 fix(docker): sync nginx upstream port with DEV_PORT
The nginx upstream was hardcoded to 127.0.0.1:5000, while gunicorn and the
readiness check bind/probe ${DEV_PORT}. With a non-default DEV_PORT the
readiness check passes but every proxied request returns 502.

nginx.conf is not run through envsubst, so move the wsgi_server upstream into
the templated default.conf.template and export DEV_PORT in the entrypoint so
the upstream port tracks the gunicorn bind.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-18 19:05:40 -04:00
Georges-Antoine Assi
cf1420bd5d Merge branch 'master' into fix/mod-zip-range-requests 2026-07-18 18:15:39 -04:00
Georges-Antoine Assi
0ca1eb5529 fix(docker): proxy nginx to gunicorn over TCP instead of unix socket
nginx workers are dropped to the `romm` user while gunicorn creates
/tmp/gunicorn.sock as root. This only worked because gunicorn's default
umask leaves the socket world-writable; on some hosts (e.g. OMV) the
worker cannot connect() and every /api request 502s with
"connect() to unix:/tmp/gunicorn.sock failed (13: Permission denied)".

Proxy over loopback TCP (127.0.0.1:5000), which gunicorn already binds,
so there is no socket file owner/mode to mismatch. Readiness now polls
the TCP port instead of waiting for the socket file.

Fixes #3809

Generated-By: PostHog Code
Task-Id: 3cb72cda-eb77-4bc0-97ab-cde365a031c9
2026-07-18 14:44:08 -04:00
Georges-Antoine Assi
9c46bfde9c Merge pull request #3731 from rommapp/posthog-code/optimize-cleanup-frequency-and-logging
Reduce RQ worker registry sweep verbosity and frequency
2026-07-15 21:00:16 -04:00
Georges-Antoine Assi
23d724f447 fix(backend): keep default RQ maintenance interval for prompt scan recovery
The registry-cleanup log noise is already suppressed by the RomMWorker log
filter, so the hourly maintenance interval was unnecessary and delayed pruning
of orphaned STARTED jobs and stale workers. The watcher's Worker.all() scan
dedupe relies on that pruning, so restore the default (~10 min) cadence.

Generated-By: PostHog Code
Task-Id: 78c8b2f8-2b03-443f-aa4c-8867c1259f2a
2026-07-15 20:02:49 -04:00
Georges-Antoine Assi
355ee14352 feat: inject ScreenScraper dev credentials at build time
Remove the hardcoded (base64-obfuscated) ScreenScraper developer
credentials from the source tree and read them from the
SCREENSCRAPER_DEV_ID / SCREENSCRAPER_DEV_PASSWORD environment variables
instead.

The official images bake the values in at build time from CI secrets via
Docker build args; local builds and source runs read them from the
environment. env.template documents the vars (commented out) so an empty
value never overrides the image's built-in credentials.

Generated-By: PostHog Code
Task-Id: 05a9b58b-4c64-4f75-af3e-d27cc4c5702f
2026-07-13 13:06:31 -04:00
Georges-Antoine Assi
315576b0de feat(backend): reduce RQ worker registry sweep verbosity and frequency
Generated-By: PostHog Code
2026-07-12 21:39:09 -04:00
Georges-Antoine Assi
52163633e5 Merge branch 'master' into claude/server-side-rom-patching-EaQck 2026-06-23 07:01:07 -04:00
zurdi
9f6138d010 Merge branch 'master' into chore/frontend-v2
Adopt master's ROM schema design (sibling_roms + files, batched
get_files_for_roms / get_siblings_for_roms) while preserving the v2-branch
features master lacks: per-user is_main_sibling on siblings and audio_meta
on rom files.

Conflict resolution:
- responses/rom.py: keep master's sibling_roms/files fields; re-graft
  is_main_sibling via SiblingRomSchema.from_rom(rom, is_main_sibling=...);
  restore the eager-relationship fallback in
  SimpleRomSchema.from_orm_with_request (None sentinel) so the v2
  /{id}/simple endpoint still returns siblings/files.
- roms_handler.py: get_siblings_for_roms now left-joins RomUser and returns
  (Rom, is_main_sibling) tuples; keep both branch and master file helpers.
- drop the redundant branch-only sibling_ids field and
  get_sibling_data_for_roms.
- generated types resolved to match (sibling_roms + files; RomFileSchema
  keeps audio_meta and gains archive_members).
- update v2 components and the RelatedGameCard mock to read sibling_roms.
- fix stale exclude={"siblings"} -> "sibling_roms" in scan emit payloads.
- re-chain the audio_meta migration as 0083 (after master's 0082) to keep a
  single Alembic head.
- package.json: union of branch tooling + master dependency bumps; lock
  regenerated.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-16 01:19:55 +02:00
Georges-Antoine Assi
21f60b64aa add smol comment 2026-06-06 10:28:02 -04:00
Georges-Antoine Assi
a69f09b7f8 cleanup 2026-06-06 10:24:08 -04:00
Claude
6d533e0a25 fix(docker): declare /romm as single volume to enable asset hardlinks
PR #3388 added hardlink-based asset import/export (os.link with a
shutil.copy2 fallback) to avoid duplicating disk space. The Dockerfile
VOLUME instruction listed each /romm subdirectory (resources, library,
assets, config, sync) separately, which makes Docker create an
independent mount point for each one — even when the user bind-mounts a
single parent at /romm. Each mount point is its own st_dev, so every
cross-directory os.link() failed with EXDEV and silently fell back to a
full copy, defeating the optimization.

Declare the parent /romm directory instead so all subdirectories share a
single filesystem and hardlinks can succeed when paths reside on the same
underlying host filesystem.
2026-06-06 14:20:29 +00:00
Georges-Antoine Assi
619e03ab32 fix: stop serving private user assets via unauthenticated nginx static route
The default Docker image symlinked /romm/assets into the nginx static web
root (/assets/romm/assets), where it was served by an unauthenticated
`location /assets { try_files ... }` block. /romm/assets holds private user
data (save files, save states, screenshots, avatars) that is meant to be
accessible only through the authenticated /api/raw/assets/{path} route
(Scope.ASSETS_READ). The static symlink bypassed that protection, letting any
unauthenticated caller read another user's files given a (guessable) path.
Avatar URLs leaked the hex user ID through the same static route, making path
construction straightforward.

Fix:
- Drop the /romm/assets symlink from the Docker image build and both
  entrypoint scripts; only /romm/resources (public cover art, screenshots,
  manuals) remains statically served.
- Point the frontend avatar URLs at the authenticated /api/raw/assets/ route
  instead of /assets/romm/assets/. Browser <img> loads authenticate via the
  existing session cookie.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-05 17:34:30 -04:00
zurdi
25d76300f4 feat: specify platform for frontend build to avoid emulation issues 2026-05-27 19:19:29 +00:00
zurdi
8f48c92cbf Merge remote-tracking branch 'origin/master' into chore/frontend-v2 2026-05-26 07:44:59 +00:00
zurdi
6f2bc8b3e3 chore: update Node.js version to 24.16 in Dockerfile 2026-05-26 07:33:38 +00:00
Georges-Antoine Assi
d4bc2418a5 Merge pull request #3428 from Spinnich/fix/m3u-crc-non-ascii-filenames
fix(nginx): use Buffer for binary-safe base64 decode in m3u endpoint
2026-05-25 08:34:03 -04:00
zurdi
17ea8da23d Merge remote-tracking branch 'origin/master' into chore/frontend-v2 2026-05-25 07:56:38 +00:00
Spinnich
e943cc7e2d fix(nginx): use Buffer for binary-safe base64 decode in m3u endpoint
atob() decodes base64 to a JS string, which r.return() then re-encodes
as UTF-8. For filenames with non-ASCII characters (e.g. Pokémon), bytes
above 0x7F get double-encoded — serving different content than what the
backend computed the CRC32 over, causing mod_zip to report CRC failure
on the .m3u file.

Buffer.from(value, 'base64') decodes directly to a byte array and
r.return() sends it verbatim, matching the CRC exactly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-25 00:16:23 +00:00
Georges-Antoine Assi
354207d683 Drop redundant out_arr reset in otel_prefix
All callers declare a fresh `local -a wrap=()` before invoking, so the
in-function reset is unnecessary.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-24 15:17:42 -04:00
Georges-Antoine Assi
a4f1f516bc Simplify OTEL wrapper helper and fix shell quoting
Collapse `otel_prefix` and `otel_prefix_str` into a single nameref-based
helper. Watchfiles call sites embed the array as a shell-quoted prefix
via `${wrap[*]@Q}`, which also fixes a quoting bug where an
`OTEL_SERVICE_NAME_PREFIX` containing a single quote would produce an
invalid command string and break the watcher.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-24 14:57:52 -04:00
Claude
f434fde772 Refactor OTEL wrapping into shared helpers
Collapse the duplicated OTEL_SDK_DISABLED / opentelemetry-instrument
branches in run_startup, start_bin_gunicorn, start_bin_watcher, and
start_bin_sync_watcher into two small helpers:

- otel_prefix: emits the wrapper as NUL-delimited argv tokens (for
  direct process invocation).
- otel_prefix_str: emits the wrapper as a shell-string prefix (for
  embedding inside `watchfiles --target-type command`).

Each call site becomes a single command instead of a 2- or 3-way
branch with a fully duplicated command body. As a side effect, the
watcher functions now also gain the `command -v opentelemetry-instrument`
fallback that the gunicorn/startup paths added.
2026-05-24 18:21:40 +00:00
copilot-swe-agent[bot]
84a0dd9ef2 Conditionally disable opentelemetry wrapper during init startup
Co-authored-by: gantoine <3247106+gantoine@users.noreply.github.com>
2026-05-24 14:14:32 +00:00
Georges-Antoine Assi
ba25477a2d changes from bot review 2026-05-17 19:07:57 -04:00
Georges-Antoine Assi
887bdad0ef mark local 2026-05-17 17:52:47 -04:00
Georges-Antoine Assi
3557850701 refactor 2026-05-17 17:52:14 -04:00
Georges-Antoine Assi
51f0522193 undo 2026-05-17 17:39:47 -04:00
Georges-Antoine Assi
ea22b06502 fix(sync): export SYNC_BASE_PATH so the Python child inherits it
The shell fallback was assigned locally but never exported, so
sync_watcher.py and the Python config layer never saw the resolved
value. They happened to land on the same /var/lib/romm/sync default by
coincidence; export it so the shell and Python defaults stay linked
through a single source of truth.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-17 17:22:54 -04:00
Georges-Antoine Assi
e5c9d0faf7 fix(sync): create SYNC_BASE_PATH at startup before watching
The prod Dockerfile creates /var/lib/romm/sync at build time, but if a
user overrides SYNC_BASE_PATH to a path that doesn't exist (or runs the
dev entrypoint, which never created the default), watchfiles fails to
start because its target directory is missing. Have both entrypoints
mkdir -p the resolved path before handing it to watchfiles.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-17 14:12:16 -04:00
Georges-Antoine Assi
10d3eb2079 feat(sync): default SYNC_BASE_PATH to /var/lib/romm/sync
Move the sync staging folder out of ROMM_BASE_PATH so it lives on a
dedicated writable mount. This lets the container run with a read-only
root filesystem without losing in-flight save uploads, and keeps
app-owned state separate from the user-curated library volume.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-17 09:28:39 -04:00
Georges-Antoine Assi
3f52ab616e fix(docker): generate gunicorn logging config to writable /tmp path
The init script ran `sed -i` against /etc/gunicorn/logging.conf, which
fails both on read-only root filesystems and when the container runs
as a non-root UID (since /etc/gunicorn is not chmod'd writable). Copy
the config to /tmp/gunicorn/logging.conf at startup and edit/use that
copy instead, leaving the image file untouched.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-16 18:14:59 -04:00
Georges-Antoine Assi
faed12e407 remove log-level from rqscheduler 2026-05-08 19:30:43 -04:00
zurdi
af53de4b29 chore: update permissions for nginx and gunicorn configuration directories 2026-04-29 13:30:43 +00:00
zurdi
0bfce43371 chore: update uv sync command to use frozen option for consistency 2026-04-27 20:34:22 +00:00
copilot-swe-agent[bot]
681efc6a46 fix: enable COEP/COOP headers for console play route to fix MSDOS games
Agent-Logs-Url: https://github.com/rommapp/romm/sessions/487d4506-1203-499e-afc4-a45ee1f2438b

Co-authored-by: gantoine <3247106+gantoine@users.noreply.github.com>
2026-04-20 18:08:38 +00:00
Dang Mai
47eb47a8f1 Small spacing fix 2026-04-17 16:26:24 -07:00
Dang Mai
a5ff6010cd Fix RAHasher prod build 2026-04-17 16:24:31 -07:00
Georges-Antoine Assi
3104a55ae1 update libretro to 1.8.3 in prod 2026-04-16 22:15:06 -04:00
copilot-swe-agent[bot]
80d20eec51 fix: bump RAHasher version from 1.8.1 to 1.8.3 in docker/Dockerfile
Agent-Logs-Url: https://github.com/rommapp/romm/sessions/59aeb3a2-1a8c-47f5-9f90-f6d537765977

Co-authored-by: gantoine <3247106+gantoine@users.noreply.github.com>
2026-04-17 01:44:30 +00:00