mirror of
https://github.com/rommapp/romm.git
synced 2026-06-27 22:35:57 +00:00
The patcher uploads the patched ROM and then fires a platform scan to register it. When a second scan runs against the same platform around the same time (a filesystem-watcher rescan, a scheduled rescan, or another manual scan on a multi-worker setup), both scans could see the new file as absent from the DB and each insert it, producing two identical library entries for one patched file. A platform folder can't physically hold two entries with the same name, so a ROM is uniquely identified by (platform_id, fs_name). Enforce that with a unique index instead of the previous plain index, which makes the duplicate impossible. The scan's early ROM insert now adopts the row created by a concurrent scan (catching the integrity error and skipping) instead of failing, and ROM rename pre-checks for a name collision so it returns a clean 409 rather than hitting the constraint. Includes a migration that removes any pre-existing duplicates (keeping the lowest id; dependents cascade) before upgrading the index to unique. Fixes #3590 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0135UV8Xn2XHkRhjzhm9UptP