Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v3.4.0 #1061

Merged
merged 86 commits into from
Aug 7, 2024
Merged

v3.4.0 #1061

merged 86 commits into from
Aug 7, 2024

Conversation

zurdi15
Copy link
Member

@zurdi15 zurdi15 commented Aug 7, 2024

What's Changed

New Contributors

Full Changelog: 3.3.0...3.4.0

adamantike and others added 30 commits July 21, 2024 18:23
Introduce an asynchronous Redis instance to be used in async functions.
Also, this change migrates most of the sync cache usage to the new async
cache.
Convert `MobyGamesHandler` methods to be asynchronous, and use an
`httpx` async client, instead of `requests` sync client.
Creates an example config file for Batocera/RetroBat-based mappings, as popular distributions so should hopefully save people a few hours.

Tested with a setup using RetroBat v6.0.3 folder structures, and only keeping matches for which I'm certain.
Create config.batocera-retrobat.yml
Updates after discovering all the extra cool icons already available (but not advertised in supported platforms!) and sorting.
Update config.batocera-retrobat.yml
For filesystem resource handler, `requests` calls have been replaced
with `httpx`, and file I/O has been replaced with `anyio` utils.

The existing approach to save covers and screenshots, by calling
`shutil.copyfileobj` with the raw response is no longer needed. `httpx`
does not provide a file-like object when streaming [1], so there's no
easy drop-in replacement.

However, the applied solution correctly builds the file iteratively, by
consuming the response in chunks.

[1] encode/httpx#2296
…e-handler-to-async

misc: Migrate filesystem resource handler to async
`pytest-vcr` [1] is no longer maintained (last commit was in 2020), and
`VCR.py` recommends [2] `pytest-recording` instead.

Also, `pytest-vcr` does not correctly support `httpx` [3].

This change also removes unused cassettes.

[1] https://github.com/ktosiek/pytest-vcr
[2] https://vcrpy.readthedocs.io/en/latest/usage.html#pytest-integration
[3] ktosiek/pytest-vcr#46
…test-recording

misc: Replace pytest-vcr dependency with pytest-recording
This change mainly refactors the `scan_platforms` function, moving part
of its logic to `_identify_platform`, `_identify_firmware`, and
`_identify_rom`.

The logic is simpler this way, each smaller function returns `ScanStats`
that can be merged by the caller, and it simplifies future performance
improvements.
misc: Refactor scan process by splitting single function
[ROMM-1025] Replace game-and-watch with g-and-w
Convert `IGDBBaseHandler` methods to be asynchronous, and use an `httpx`
async client, instead of `requests` sync client.

This change also removes the direct dependency with `requests`, as the
project no longer uses it, preferring `httpx` instead.
`ASYNC` rules [1] tries to find issues regarding asynchronous code. This
change enables `ruff` to start reporting these issues, and fixes
existing warnings.

[1] https://docs.astral.sh/ruff/rules/#flake8-async-async
fix: Enable flake8-async rules in ruff and fix warnings
This improvement avoids extra IGDB API requests when a received Rom is
an exact match. It avoids up to 2 requests per Rom, when an exact match
is found.
Only for this scheduled task, the run was failing because there was no
context initialization that created the httpx session.

Other schedules work as expected, because they do have context
initialization in the functions they call to (e.g. `scan_platforms`).
HellLord77 and others added 28 commits August 2, 2024 19:33
[ROMM-1012] Fix multi-file download in gakllery view
[ROMM-1031] Remove persistent overlay prevents back navigation
Co-authored-by: Zurdi <34356590+zurdi15@users.noreply.github.com>
[ROMM-1019] Clickable filter buttons on details view
[ROMM-1022] Add button to show duplicates
Add workflow that runs typecheck on PRs
Fix FastAPI and nginx configuration, to make the application correctly
redirect URLs. This is specially useful when URLs ended with forward
slash are redirected to their stripped version.

Included changes:
* Stop removing the `/api` prefix in nginx rewrite rules, so FastAPI
  knows what's the original URL path being requested.
* Use `$http_host` in nginx, so FastAPI receives both the original host
  and port, to build the redirect URL (as `$host` does not include the
  port, if present).
* Make all FastAPI included routers know their prefix, to correctly
  route incoming requests.

This fix was found based on a report that redirects from URLs ended with
forward slash were not working [1].

[1] #1051 (comment)
According to multiple FastAPI discussions [1], FastAPI only includes a
built-in mechanism to redirect requests including a trailing slash, to
its variation without slash, using a `307` status code.

This can be an issue when certain clients do not send the same headers
on the redirected request.

This change adds a custom FastAPI `APIRouter`, that registers both route
path variations (with and without trailing slash), while only marking
the path without slash for being included in the OpenAPI schema.

[1] fastapi/fastapi#7298
misc: Make backend handle URLs with trailing slash
Drop ROMM_AUTH_USERNAME and ROMM_AUTH_PASSWORD env variables
Copy link

github-actions bot commented Aug 7, 2024

Test Results

82 tests   82 ✅  23s ⏱️
 1 suites   0 💤
 1 files     0 ❌

Results for commit 51ee99e.

@zurdi15 zurdi15 merged commit 348fc8d into release Aug 7, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants