Commit Graph

14 Commits

Author SHA1 Message Date
Spinnich
e1225c8a9c fix(screenscraper): don't repeat an unchanged quota line
The last platform's quota readout and the end-of-scan summary both call
_log_ss_quota, so a completed scan printed the same numbers twice in a row.
Skip a line identical to the previous one, resetting at the start of each scan
so a new run always reports.
2026-07-29 01:30:18 +00:00
Spinnich
5fb27a55f9 feat(screenscraper): make scanning aware of the account's reported limits
ScreenScraper returns the account's allowances on every response, but only
maxthreads was read. Use the rest:

- Pace requests against the reported maxrequestspermin (falling back to the
  documented threads x 50), so fast lookups can no longer overrun the
  per-minute budget without ever exceeding the thread cap.
- Report the remaining daily and unrecognized-ROM quotas after each platform
  and at the end of a scan, and warn once when either drops below 10%.
- Hint once per scan when SCAN_WORKERS is below the thread allowance (scans
  slower than the account allows) or above it (extra workers just queue).
- Raise a distinct error when a request is refused twice for exceeding the
  rate, so the ROM is reported as skipped in the scan summary instead of being
  saved with no ScreenScraper data.
- Route ScreenScraper media downloads (covers, screenshots, manuals, mixed
  media) through the same limiters, since they are api2 endpoints that count
  against the same allowances, and derive their timeout from the account's
  advertised download speed.

Fixes #3978

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-28 17:09:52 +00:00
Ryan McClelland
32f9ac1b90 fix(resources): handle write failures when the disk is full
The streamed resource downloads wrapped their writes in `except
httpx.TransportError`, which does not cover the `OSError` raised by
`f.write()` when the filesystem is out of space. The error escaped the
handler and the partially written file stayed on disk.

A truncated file is worse than a missing one: it satisfies the
`cover_exists` / `screenshots_exist` checks and the `file_exists` guards
in `store_ra_badge` and `store_media_file`, so later scans skip it and
never refetch it. The artwork stays permanently corrupt.

Catch `OSError` on every resource write path (covers, screenshots,
manuals, RA badges, media files and uploaded artwork) and remove the
partial file so the next scan refetches it. A stream that drops
mid-transfer leaves the same truncated file, so the transport-error
branches now discard it too. The cleanup helper swallows its own
`OSError` so it can never mask the original failure.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 13:34:41 -07:00
Georges-Antoine Assi
579e12574c fix(backend): discard ScreenScraper chroma-key green placeholder art
ScreenScraper serves a solid chroma-key green (#00FF00) square when a
requested image (box-2D front/back/side) doesn't exist. RomM stored it as
real artwork, so the v2 3D box painted a bright green face and the flat
cover showed green in the gallery.

Detect the placeholder at download time and drop it: covers fall back to
the procedural placeholder, and a discarded box-2D face falls back to the
dark cover placeholder the box already paints (rather than bright green).

- Add _is_chroma_key_placeholder + _discard_if_chroma_key in the resources
  handler; wire into _store_cover and store_media_file.
- store_media_file also cleans up pre-existing green files on rescan.

Generated-By: PostHog Code
Task-Id: 5534668f-a2b6-4575-b6c1-73dcd965062c
2026-07-11 07:57:36 -04:00
Georges-Antoine Assi
e7de380aac fix(roms): restrict manual matching to allowed extensions
Discover manuals only for the allowed extensions (.pdf, .md) instead of
globbing {rom.id}.*, so stray files (e.g. {rom.id}.part) are never treated
as a manual. Select deterministically by newest mtime when multiple allowed
manuals coexist. Drop the redundant .md token from the frontend accept lists.

Generated-By: PostHog Code
Task-Id: 1d785bcc-ea5c-4b99-b619-73625a9e218c
2026-07-05 12:20:41 -04:00
Georges-Antoine Assi
82bd5e30b8 feat(roms): support markdown manuals and enforce allowed file types
Generated-By: PostHog Code
2026-07-05 08:49:47 -04:00
Georges-Antoine Assi
5a63f0d1be fixing failing tests 2026-07-01 10:44:00 -04:00
Georges-Antoine Assi
f227a3145d changes from bot review 2026-04-07 22:32:40 -04:00
Georges-Antoine Assi
438f514e76 fix tests 2025-10-28 11:38:57 -04:00
Georges-Antoine Assi
c1ac9a2133 fix screenshots dissapearing on scan 2025-10-28 11:00:45 -04:00
Georges-Antoine Assi
8975a7ed89 fix ra tests 2025-10-26 14:02:21 -04:00
Georges-Antoine Assi
bbade3e40e fix tests 2025-10-23 17:05:23 -04:00
Michael Manganiello
e4e3928d1b misc: Apply import sorting 2025-09-04 11:17:00 -03:00
Michael Manganiello
ba21cbc1e1 misc: Separate tests folder from backend code
Create separate `tests/` folder for all tests. This will also simplify
not copying tests code into the Docker image.
2025-08-08 12:49:13 -03:00