mirror of
https://github.com/rommapp/romm.git
synced 2026-11-29 01:58:41 +01:00
The Files tab streamed chunks through /roms/upload/* and registered the result with the scanner listing, while each Media route (soundtracks, screenshots, manual files, walkthrough files) carried its own copy of the sanitize, promote, mkdir, stream, stat and DB upsert sequence. Those copies crashed with FileNotFoundError on a file name outside Latin-1: the browser sends the header as Latin-1 and the multipart field name as UTF-8, so the parser target registered under the header name never received the part and os.stat failed after the folder had been created. handler/rom_upload.py now owns the shared ingestion (resolve and prepare the destination, stage next to the target, move into place, refresh the ROM's file rows through the scanner) and both the chunked completion and a new receive_rom_file sit on it. The media routes only check the extension and delegate; a body naming the part differently is a 400. /start gains an optional body filename that wins over the header, so names outside Latin-1 arrive intact, and rom_id becomes optional in that body. On the v2 frontend a single useRomFileUpload composable wraps the chunked upload, the single-file conversion prompt, the toasts and the refetch; the Files tab, Soundtrack panel, Screenshots subtab, Walkthrough subtab and the manual "add to ROM folder" target all call it with their folder. The service sends the real name in the body and a percent-encoded one in the header. The v2-only uploadScreenshots/uploadWalkthroughFiles service functions and the soundtrack-only toasts are gone. Media subtabs now refuse an existing file name (409) like the Files tab, instead of overwriting it silently. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01X1FgnCzXjM3rzkxggi7g6C