Commit Graph

10889 Commits

Author SHA1 Message Date
Georges-Antoine Assi
ca455778da Merge pull request #3919 from rommapp/feature/netplay-username-from-account
Default EmulatorJS netplay username to the RomM account
2026-07-23 18:20:41 -04:00
Georges-Antoine Assi
fa63d7b5b5 Merge pull request #3917 from rommapp/feature/scan-region-mode
Add scan.priority.region_mode to let config regions drive media selection
2026-07-23 18:11:18 -04:00
Georges-Antoine Assi
36b7c228bc Address review: guard region_mode type and scope it to media
Non-string region_mode values (YAML list/mapping) now take the
warn-and-fallback path instead of raising TypeError on the frozenset
membership check during startup.

get_preferred_regions only applies prefer_config reordering when
selecting media (for_media=True); name and release-date selection keep
the rom-tags-first ordering, matching the documented scope.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-23 17:52:44 -04:00
Georges-Antoine Assi
47fb79630c cleanup 2026-07-23 17:11:23 -04:00
Georges-Antoine Assi
36e86dce30 Merge pull request #3918 from rommapp/fix/duplicate-media-screenshots
Stop storing fanart and title_screen twice when screenshots are enabled
2026-07-23 17:09:03 -04:00
Georges-Antoine Assi
b100392db2 Merge pull request #3916 from rommapp/fix/playmatch-health-check
Fix Playmatch health check failing on plain-text response
2026-07-23 16:52:43 -04:00
Georges-Antoine Assi
00fe9ccddb Default EmulatorJS netplay username to the RomM account
EmulatorJS keeps the netplay player name in memory only and shows its
name popup whenever netplay.name is unset, forcing users to retype a
name every session. Preset it from the logged-in RomM username in the
existing netplay override block, so the popup is skipped and the
account name is used automatically.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-23 16:48:21 -04:00
Georges-Antoine Assi
6666019ce5 Stop duplicating fanart and title_screen into screenshots
ScreenScraper scraping added the fanart and title-screen URLs to
url_screenshots even though the same images are persisted to their
dedicated fanart/ and title_screen/ media folders, downloading and
storing every image twice. Restrict url_screenshots to the actual
screenshot media type; the dedicated media still renders in the artwork
gallery. The gamelist handler had the same pattern with title_screen
and gets the same fix.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-23 16:47:22 -04:00
Georges-Antoine Assi
67eab49a72 Add scan.priority.region_mode to prefer config regions for media
New opt-in config key scan.priority.region_mode with values
prefer_rom_tags (default, current behavior) and prefer_config. With
prefer_config, the configured region priority outranks the rom's
filename region tags when selecting ScreenScraper media, and the rom's
own tags remain the fallback when the configured regions have no media.
Unknown values warn and fall back to prefer_rom_tags, and the key
survives runtime config-file rewrites.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-23 16:46:38 -04:00
Georges-Antoine Assi
a82615f4a7 Treat Playmatch plain-text health response as healthy
The Playmatch /api/v2/health endpoint returns the plain-text body
"Healthy", but heartbeat() routed it through the JSON-parsing
_request(), so decoding always failed and the Metadata Sources page
showed "Connection failed" for a healthy service. Do a raw GET and
treat any 2xx response as healthy, matching the Hasheous handler.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-23 16:45:54 -04:00
Georges-Antoine Assi
a144d117e8 Merge pull request #3910 from Spinnich/fix/server-stats-breakdown-perf
perf(stats): aggregate Server Stats breakdowns from roms_facets
2026-07-23 16:04:55 -04:00
Georges-Antoine Assi
c1065f3be1 fix migrations 2026-07-23 15:59:47 -04:00
Georges-Antoine Assi
e2827b9886 Merge branch 'master' into fix/server-stats-breakdown-perf 2026-07-23 15:50:08 -04:00
Georges-Antoine Assi
5744e2e518 Merge pull request #3896 from tmgast/feature/music-playlists
Add music favorites and playlists API
2026-07-23 15:14:54 -04:00
Georges-Antoine Assi
1bdd77661e cleanup 2026-07-23 14:44:56 -04:00
Spinnich
70478c88d3 fix(stats): degrade gracefully when the stats breakdown fetch fails
The v2 Server Stats view loads the summary first, then the heavier
per-platform breakdown as a second request. A rejection from that second
request propagated out of the async lifecycle hook as an uncaught error
instead of leaving the summary and platform rows usable. Catch it so the
page degrades to partial data.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-23 18:42:18 +00:00
Spinnich
f69e4756a7 perf(stats): aggregate server-stats breakdowns from roms_facets
The Server Stats page ran two full scans of the multi-gigabyte `roms`
table on every visit: the metadata-coverage breakdown counted eleven
provider-id columns per platform, and the region breakdown pulled every
row's regions into Python. Both were returned in the same request as the
cheap summary counts, so the whole page stayed blank until they finished.

Mirror the provider match ids into the narrow `roms_facets` table
(migration 0102, kept in sync by the same triggers as the existing facet
columns) and read both breakdowns from it, so neither query touches
`roms`. Split the v2 Server Stats view into a summary-first request and a
separate breakdown request so the six top cards render immediately.

Fixes #3901

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-23 17:27:09 +00:00
Georges-Antoine Assi
6b2e805b0d Merge pull request #3906 from Spinnich/fix/server-stats-duplicate-slug-key
Fix/server stats duplicate slug key
2026-07-23 12:50:06 -04:00
Georges-Antoine Assi
c99154a5d0 Merge pull request #3903 from rommapp/fix/emit-restored-roms-during-platform-scan
fix(scan): emit a client update for ROMs that are no longer missing
2026-07-23 12:48:24 -04:00
Spinnich
bc073f6ace Merge remote-tracking branch 'upstream/master' into fix/server-stats-duplicate-slug-key
# Conflicts:
#	frontend/src/v2/components/Settings/PlatformsStatsSection.test.ts
2026-07-23 16:08:56 +00:00
Georges-Antoine Assi
75b10591ae refactor(music): extract the track cover url fallback
Pull the cover priority (embedded track cover, then the game's cover art)
out of from_row into a named helper on the schema, and cover the no-art
case that the endpoint tests didn't reach.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-23 12:05:21 -04:00
Georges-Antoine Assi
e5875405e9 refactor(migrations): use if_not_exists in the music playlists migration
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-23 11:55:57 -04:00
Spinnich
889f73f37e test(v2): fix stale row-count comment in platform stats test
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-23 15:37:56 +00:00
Georges-Antoine Assi
a84ad2289d refactor(music): key playlists and favorites on rom_file_id
Rescans reconcile rom_files in place since #3900, so file ids survive a
rescan and no longer need routing around. Playlist and favorite entries
reference rom_file_id directly instead of (rom_id, md5_hash).

This drops the machinery the hash key required: soundtrack audio is no
longer force-hashed during scans (which overrode NON_HASHABLE_PLATFORMS
and SKIP_HASH_CALCULATION), soundtrack uploads no longer hash on write,
adding an unhashed track no longer returns 400, and the min(file id)
subquery that collapsed identical copies within a rom is gone. Two files
with the same content are now two independently addressable tracks.

A file that leaves the library takes its entries with it via the FK
cascade, rather than leaving a dangling entry that resurrects if the
content comes back.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-23 10:58:53 -04:00
Georges-Antoine Assi
8c5e3d8eae Merge branch 'master' into feature/music-playlists 2026-07-23 10:48:53 -04:00
Georges-Antoine Assi
2e93509828 Merge pull request #3900 from rommapp/fix/stable-rom-file-ids-on-rescan
fix(scan): reconcile rom_files in place instead of purging them
2026-07-23 10:46:29 -04:00
Georges-Antoine Assi
559cc7f7ea fix(scan): keep a soundtrack cover path when its unlink fails
remove_persisted_cover swallowed OSError, so clearing cover_path
regardless dropped the only reference to a file still on disk. It now
reports whether the file is gone, and the path is kept for the next scan
to retry when it isn't.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-23 10:41:30 -04:00
Georges-Antoine Assi
5548f314d5 refactor(scan): fold track metadata into the rom file reconciliation
The two halves always ran together, and the column copy they shared is
now a single helper.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-23 10:32:26 -04:00
Spinnich
a30965d27f fix(v2): key Server Stats platform rows by id, not slug
The per-platform breakdown v-for was keyed by platform.slug, which is
the metadata slug and is not unique across platform records (variant
sets like official + "(Unofficial)" or headered/headerless share one
slug while id/fs_slug stay unique). With duplicate keys Vue cannot map
old rows to new ones on a list update, so searching or re-sorting leaves
stale DOM rows behind and the list grows past the library size with
wrong/duplicate rows. Vue's duplicate-key warning is stripped from the
production build, so it failed silently.

Key by platform.id (the DB primary key, already used elsewhere in the
same template) so every row has a stable unique key.

Fixes #3905

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-23 14:27:47 +00:00
Georges-Antoine Assi
58286db20e Merge pull request #3899 from Spinnich/fix/server-stats-empty-platforms
fix(v2): hide empty platforms in Server Stats breakdown
2026-07-23 10:14:51 -04:00
Georges-Antoine Assi
1ee41f9a66 fix(scan): don't write NULL over NOT NULL columns when reconciling files
A scanned row leaves unset columns as None and the model defaults only
apply on insert, so the reconciliation path could write NULL into
file_size_bytes or has_embedded_cover. Unset values now leave the stored
value alone.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-23 10:08:01 -04:00
Georges-Antoine Assi
5a109135a9 cleanup 2026-07-23 10:07:48 -04:00
Georges-Antoine Assi
d9050eb4cc fix(scan): unlink soundtrack covers orphaned by dropped track metadata
A file that stopped carrying audio tags, or vanished from disk, had its
track_meta row dropped (directly or by cascade), leaving its persisted
cover on disk with nothing pointing at it.

sync_rom_files now reports those cover paths so the scan unlinks them,
keeping filesystem work out of the database handler.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-23 09:44:12 -04:00
Georges-Antoine Assi
71c04f186b fix(scan): emit a client update for ROMs that are no longer missing
A platform scan already clears `missing_from_fs` for an entry whose file
came back under the same name, but the ROM is skipped by `should_scan_rom`
so nothing emits `scan:scanning_rom` for it. An open gallery keeps showing
the stale "missing" badge until a refetch, which reads as the platform scan
ignoring missing games (a single-game scan does emit, and looks fixed).

Snapshot the flagged ids before the pre-loop sync clears them, then emit for
the restored entries after `bulk_mark_present`.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-23 09:40:17 -04:00
Georges-Antoine Assi
21cc044bf1 fix(scan): clear a soundtrack cover that's gone from the audio file
Reusing the file row across rescans meant a track that kept its tags but
lost its embedded cover held on to the old cover_path, so the music API
kept serving an obsolete image and its file was never removed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-23 09:24:19 -04:00
Georges-Antoine Assi
83ad2b3132 fix(scan): reconcile rom_files in place instead of purging them
Rescans deleted and re-inserted every rom_files row, so file ids churned
on each scan and anything keyed on them (track metadata, persisted
soundtrack covers) was orphaned.

Rows are now matched by path first, then by content hash so a file
renamed or moved inside the ROM keeps its id, mirroring the ROM-level
reassociation. Only changed columns are written, vanished files are
deleted, and archive_members is carried over (the hand-written copy
dropped it).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-23 08:54:50 -04:00
Spinnich
5ac3d07a7d fix(v2): hide empty platforms in Server Stats breakdown
The per-platform breakdown rendered the raw allPlatforms list, so empty
(0-game) platforms left in the DB leaked through. The Platforms page, Home
screen, and this page's own summary counter all exclude them, so the list
disagreed with everything else.

Switch to the shared filledPlatforms getter (rom_count > 0) so the list is
consistent by construction with the rest of the app.

Fixes #3897

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-23 12:35:05 +00: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
42059a41d6 Merge pull request #3887 from rommapp/fix/rar-archive-hashing
fix(archives): read RAR archives through bsdtar so they can be hashed
2026-07-23 08:08:37 -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
Georges-Antoine Assi
969d9b3f9e fix(archives): fail archive hashing when a member can't be read
A member that failed or timed out mid-archive ended the member stream
silently, so the caller kept the composite hash built from the members
that happened to succeed. Raise ArchiveReadError instead and fall back to
hashing the archive's raw bytes, with no archive_members recorded.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-23 07:37:39 -04:00
nendo
8a39bf0b20 Address review: per-row insert conflict handling and scoped append dedupe
A concurrent duplicate no longer rolls back the whole batch and reports
zero added; each row inserts under its own savepoint, so conflicting rows
skip and the rest land with a truthful count. The pre-insert dedupe query
now filters to the candidate rom ids instead of loading every existing
entry for the playlist or user.
2026-07-23 15:47:05 +09:00
nendo
70e583b9a0 Add music favorites and playlists API
Spotify-style library features for soundtrack tracks: per-user favorites
(liked songs) and user-owned playlists with manual ordering and optional
public read-only sharing.

Track references are stored as (rom_id, md5_hash) rather than rom_file_id:
scans purge and re-insert rom_files rows, so file ids churn while rom ids
and content hashes are stable. Entries survive rescans and renames, and
resolve to the current file at query time; entries whose content is gone
are omitted from listings until the file returns.

To make the content hash reliably present, soundtrack audio files are now
always hashed individually during scans (including NON_HASHABLE_PLATFORMS
and SKIP_HASH_CALCULATION, whose file-size concerns don't apply to audio),
and soundtrack uploads compute crc/md5/sha1 on write. Existing libraries
backfill via a HASHES scan; adding an unhashed track returns 400.

New playlists.read/playlists.write scopes are wired through the granular
permission system (PermEntity.PLAYLISTS); the migration mirrors every
group's collections grants onto the playlists entity so existing groups
keep working without admin intervention.

Endpoints under /api/music: favorites GET/POST/DELETE, is_favorite and
md5_hash on track rows, playlists CRUD, playlist tracks GET/POST/DELETE
and PUT /tracks/order.
2026-07-23 15:32:32 +09:00
Georges-Antoine Assi
31483225ba Merge pull request #3886 from rommapp/perf/materialize-virtual-collections
perf(backend): materialize virtual collection membership
2026-07-22 22:00:25 -04:00
Georges-Antoine Assi
91e098614e perf(backend): look up virtual collection covers per collection
_attach_covers ranked every membership row with a window function and
only then kept the first five per collection, so the collection list kept
a full scan proportional to library size (0.77s of a 0.92s list on a 50k
rom library) even though the view lookup itself is now indexed.

Each collection instead gets its own primary-key lookup capped at
MAX_VIRTUAL_COLLECTION_COVERS, batched into UNION ALL statements, so the
cost follows the number of collections. The covers returned are
unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-22 21:52:59 -04:00
Georges-Antoine Assi
535668f593 rename file 2026-07-22 20:35:13 -04:00
Georges-Antoine Assi
15554f905e Merge branch 'master' into perf/materialize-virtual-collections 2026-07-22 20:17:16 -04:00
Georges-Antoine Assi
abe0ed4aa5 Merge pull request #3885 from rommapp/perf/roms-facets-table
perf(backend): mirror ROM filter values into a narrow trigger-maintained table
2026-07-22 20:00:43 -04:00
Georges-Antoine Assi
2c1e12a7ad perf(backend): backfill roms_facets before installing the triggers
Migrations run at startup before the app serves traffic, so no write can
race the backfill. Populating the empty table first means no row can
conflict, dropping the per-engine upsert guards and collapsing the two
backfill statements into one.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-22 19:51:08 -04:00