mirror of
https://github.com/rommapp/romm.git
synced 2026-11-29 01:58:41 +01:00
POST /api/states is a filename upsert: get_state_by_filename matches on
(rom_id, user_id, file_name) with no emulator scoping, while the bytes are
written under a path derived from this request's emulator. The upsert branch
only wrote file_size_bytes, so re-uploading the same filename under a
different emulator left the row pointing at the previous emulator's folder
while reporting the new file's size. GET /api/states/{id}/content then served
the old state, and the freshly written bytes were orphaned on disk.
Persist file_path/emulator alongside the size, and drop the bytes at the old
location when no other row still references them. This mirrors the fix
already applied to POST /api/saves in #3833.
Co-Authored-By: Claude <noreply@anthropic.com>