Commit Graph

5 Commits

Author SHA1 Message Date
nendo
c33a3e65df fix(roms): keep a failed promotion from destroying another's folder
The lock only covers one worker, so a deployment running several can
still race. A rollback now moves the ROM back only if this call moved
it, and drops the destination only while it is empty: removal is
recursive, and a folder with anything left in it belongs to the
promotion that won.
2026-08-31 14:23:14 +09:00
nendo
86b6f45f75 fix(roms): stop a racing upload from undoing a folder conversion
Uploading several files fires a request per file, and each one promotes
the same single-file ROM. Both read it as single-file, both clear the
collision check, then one moves the ROM into the new folder and the
other finds nothing at the old path. Its rollback assumed the file at
the destination was its own and moved it back out, leaving the ROM
beside the folder while the database recorded the conversion.

Promotions for a ROM now take a lock and re-read it, so the second
request sees a folder ROM and returns instead of racing.
2026-08-31 13:43:37 +09:00
nendo
40fc9c2ff9 Address review: PG years facet, LIKE escaping, lazy track_meta, migration idioms
- Cast year to text in the /api/music years facet search so Postgres does
  not error on lower(integer) (MariaDB/SQLite auto-cast, hiding it in CI)
- Escape LIKE wildcards in music search via new utils.database.escape_like
- Drop lazy="selectin" on RomFile.track_meta; eager-load only where the
  metadata is serialized (get_rom already did; add the three soundtrack reads)
- Migration backfill uses a single query + fetchmany (repo idiom, see 0084)
  instead of manual keyset paging, in both directions
- Guard the extensionless folder-conversion collision (stale row over a
  directory the user already created on disk)
- Renumber migration 0093 -> 0094 after 0093_states_rom_user_index landed
2026-07-02 11:24:12 +09:00
nendo
1f45c8123c Address review: guard FS moves in the conversion rollback, fix ROM casing
- Wrap the filesystem moves (not just the DB write) in the conversion's
  rollback so any failure restores the original layout instead of stranding
  the file under .romm_tmp_; covered by a new test.
- Use "ROM" rather than "rom" in the convert-to-folder confirm copy.
2026-07-02 11:16:07 +09:00
nendo
8a94854b81 Add a music query API for soundtracks
RomM stores soundtracks but exposes no way to consume them as a music library: a
client has to enumerate ROMs and pull each one's tracks individually, and the
per-track metadata lives in the `rom_files.audio_meta` JSON blob, which is
unindexable on MariaDB, so any library-wide filter or sort degrades to a full
scan.

This adds a queryable, music-first API for soundtracks, backed by a typed and
indexed `track_meta` table migrated from that JSON.

It also lets users upload soundtracks, manuals, and screenshots to any ROM, not
only folder-based ones. When the target is a single-file ROM, the client warns
that the upload will migrate it to a multi-file (folder) structure, then performs
that migration in place automatically.
2026-07-02 11:16:07 +09:00