Commit Graph

4097 Commits

Author SHA1 Message Date
Michael Manganiello
2bfc3c4c7e misc: Refactor scan process by splitting single function
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.
2024-07-25 10:29:46 -03:00
Georges-Antoine Assi
e7e37f4680 Merge pull request #1021 from rommapp/misc/replace-pytest-vcr-with-pytest-recording
misc: Replace pytest-vcr dependency with pytest-recording
2024-07-24 17:57:17 -04:00
Michael Manganiello
959e896aa3 misc: Replace pytest-vcr dependency with pytest-recording
`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] https://github.com/ktosiek/pytest-vcr/issues/46
2024-07-24 12:39:41 -03:00
Michael Manganiello
158b16c2c1 Merge pull request #1017 from rommapp/misc/migrate-filesystem-resource-handler-to-async
misc: Migrate filesystem resource handler to async
2024-07-24 11:06:59 -03:00
Michael Manganiello
56066d6765 misc: Migrate filesystem resource handler to async
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] https://github.com/encode/httpx/discussions/2296
2024-07-24 00:18:17 -03:00
Georges-Antoine Assi
c81fe52820 Merge pull request #1016 from TyroneSlothrop/patch-2
Update config.batocera-retrobat.yml
2024-07-23 21:00:17 -04:00
Tyrone Slothrop
cfd2e129a0 Update config.batocera-retrobat.yml
Updates after discovering all the extra cool icons already available (but not advertised in supported platforms!) and sorting.
2024-07-24 00:15:29 +01:00
Michael Manganiello
b9da72832d Merge pull request #1011 from rommapp/misc/migrate-moby-handler-to-async
misc: Migrate MobyGamesHandler to async
2024-07-23 11:10:27 -03:00
Michael Manganiello
7c6dfa8e50 feat: Use ContextVar to share httpx AsyncClient instance between requests 2024-07-23 01:29:32 -03:00
Georges-Antoine Assi
634e68eaf3 Merge pull request #1013 from TyroneSlothrop/patch-1
Create config.batocera-retrobat.yml
2024-07-22 17:10:21 -04:00
Georges-Antoine Assi
52a96058c4 Merge branch 'master' into patch-1 2024-07-22 16:57:24 -04:00
Tyrone Slothrop
bb01cf62cc Create config.batocera-retrobat.yml
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.
2024-07-22 21:50:53 +01:00
Michael Manganiello
6d8a8714f5 misc: Migrate MobyGamesHandler to async
Convert `MobyGamesHandler` methods to be asynchronous, and use an
`httpx` async client, instead of `requests` sync client.
2024-07-22 01:09:36 -03:00
Michael Manganiello
e1cec57c55 Merge pull request #1010 from rommapp/misc/add-async-cache
misc: Add Redis async cache
2024-07-21 21:57:44 -03:00
Michael Manganiello
6eb8e6aeff misc: Add Redis async cache
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.
2024-07-21 18:23:19 -03:00
Michael Manganiello
0a7fd2a515 Merge pull request #1009 from rommapp/fix/use-specific-session-cookie-name
fix: Use namespaced cookie for session
2024-07-21 01:12:41 -03:00
Michael Manganiello
1ce20cdcfc fix: Use namespaced cookie for session
Avoid conflicting cookie names when RomM runs in the same host as other
applications, by adding a `romm_` namespace to the session cookie.
2024-07-20 21:06:28 -03:00
Zurdi
0eac452377 Merge pull request #989 from rommapp/master
v3.3.0
3.3.0
2024-07-19 23:25:16 +02:00
Zurdi
dd4f9e4c63 Merge pull request #1008 from rommapp/catch-json-decode-errs-0022
Catch and ignore json decode errors in 0022 migration
2024-07-19 17:29:48 +02:00
Georges-Antoine Assi
bfeddcf623 Catch and ignore json decode errors in migration 2024-07-18 21:01:57 -04:00
Georges-Antoine Assi
3073e16ca9 Merge pull request #1006 from adamantike/fix/handle-switch-titledb-empty-product-id
fix: Filter Switch titledb entries with empty id
2024-07-18 10:15:11 -04:00
Michael Manganiello
04b64f1d97 fix: Filter Switch titledb entries with empty id
The existing code was failing after changes on the upstream JSON file
that included entries with `null` ID.
2024-07-18 11:00:30 -03:00
Zurdi
27c5749ac5 Merge pull request #1004 from rommapp/romm-1003
[ROMM-1003] Fix aborting mid-scan
2024-07-16 08:27:56 +02:00
Georges-Antoine Assi
6ec091e5da [ROMM-1003] Fix aborting mid-scan 2024-07-15 13:08:52 -04:00
Zurdi
da295bc14a Merge branch 'release' into master 2024-07-15 10:02:14 +02:00
Zurdi
7617daf232 Merge pull request #1002 from rommapp/fix-delete-cover-on-rescan
Fix covers deleted when uploading extension other then PNG
2024-07-15 10:00:47 +02:00
Georges-Antoine Assi
d05a539871 Fix covers deleted when uploading extension other then PNG 2024-07-14 17:30:05 -04:00
Georges-Antoine Assi
d8ffc1a309 Merge pull request #999 from adamantike/misc/enable-gzip-compression
misc: Enable GZip compression for backend responses
2024-07-14 11:12:55 -04:00
Georges-Antoine Assi
f1f8dd6005 Merge pull request #1001 from rommapp/dependabot/npm_and_yarn/frontend/braces-3.0.3
Bump braces from 3.0.2 to 3.0.3 in /frontend
2024-07-14 11:03:38 -04:00
Georges-Antoine Assi
3dc48638d8 Merge pull request #998 from adamantike/fix/avoid-unneeded-recursive-os-walk
fix: Avoid recursive os.walk calls
2024-07-14 11:03:20 -04:00
dependabot[bot]
08de3e4a64 Bump braces from 3.0.2 to 3.0.3 in /frontend
Bumps [braces](https://github.com/micromatch/braces) from 3.0.2 to 3.0.3.
- [Changelog](https://github.com/micromatch/braces/blob/master/CHANGELOG.md)
- [Commits](https://github.com/micromatch/braces/compare/3.0.2...3.0.3)

---
updated-dependencies:
- dependency-name: braces
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-07-14 14:21:08 +00:00
Michael Manganiello
d94f5428a8 misc: Enable GZip compression for backend responses
With the introduction of non-paginated responses for ROMs, JSON
responses for big collection could easily be at >1MiB.

This change adds a FastAPI-provided middleware to enable GZip
compression for responses greater than 1KiB.
2024-07-13 16:10:46 -03:00
Michael Manganiello
f20a9ffe34 fix: Avoid recursive os.walk calls
`os.walk` is a generator that can iteratively navigate from the
specified path, top-bottom. However, most of the calls to `os.walk` in
the project cast the call to `list()`, which makes it traverse the path
and recursively find all nested directories.

This is commonly not needed, as we end up just using a `[0]` index to
only access the root path.

This change adds a few utils that simplifies listing files/directories,
and by default does it non-recursively. Performance gains shouldn't be
noticeable in systems with high-speed storage, but we can avoid the edge
cases of users having too many nested directories, by avoiding unneeded
I/O.
2024-07-13 15:30:04 -03:00
Zurdi
1329dbbbc3 Merge pull request #996 from rommapp/fix-nav-guards-returns
Have navigation guards return true or explicitly call next
2024-07-12 08:21:04 +02:00
Georges-Antoine Assi
9b3aa45d89 Have navigation guards return true or explicitly call next 2024-07-11 22:28:19 -04:00
Zurdi
9991aaa3e5 Merge pull request #993 from rommapp/fix/download-removed-cover
Fixed re-download lost covers
3.3.0-rc.2
2024-07-11 17:15:00 +02:00
Zurdi
6d6cb35cda Merge pull request #992 from rommapp/fix/collections-migration
Avoid orphan collections table on migration fail
2024-07-11 17:13:30 +02:00
zurdi
884e7a35ac fixed re-download lost covers 2024-07-11 08:47:59 +02:00
Zurdi
da6adfe719 fixed if not exists collections logic 2024-07-10 23:47:44 +02:00
Zurdi
a2c55de602 create collections table if not exists 2024-07-10 23:30:10 +02:00
Zurdi
7ac11a1156 avoid orphan collections table on migration fail 2024-07-10 22:21:07 +02:00
Zurdi
7590fd3ee5 Merge pull request #991 from adamantike/feat/use-async-requests-for-sgdb
feat: Use async requests to retrieve SteamGridDB covers
2024-07-10 09:02:11 +02:00
Michael Manganiello
b61bb11bce feat: Use async requests to retrieve SteamGridDB covers
This change avoids blocking requests when retrieving covers from
SteamGridDB, which is the main bottleneck as the current implementation
iterates over paginated results for multiple games.

Using an asynchronous client like `httpx` provides a good performance
improvement, and reduces the latency when calling this endpoint.
Also, the inclusion of FastAPI `lifespan` allows instantiating a single
client on startup.

When testing with "Final Fantasy V Advance", the endpoint goes from ~9s
to ~1.5s to retrieve all covers.
2024-07-09 22:37:14 -03:00
Zurdi
c82ae97869 Merge pull request #990 from rommapp/fix/fixes-from-trunk
Fixed everything from trunk
3.3.0-rc.1
2024-07-09 15:06:00 +02:00
Zurdi
300262eb08 Merge branch 'master' into fix/fixes-from-trunk 2024-07-09 15:03:49 +02:00
Zurdi
008d62aaa6 Update CHANGELOG.md
Co-authored-by: Georges-Antoine Assi <3247106+gantoine@users.noreply.github.com>
2024-07-09 15:03:06 +02:00
zurdi
05939eccf1 platform icon on card tweaked 2024-07-09 15:01:45 +02:00
Zurdi
13723278ba Merge pull request #988 from rommapp/fix/config-example
Fix config.example.yml
2024-07-09 14:47:41 +02:00
zurdi
f7b14b43d6 fixed everything from trunk 2024-07-09 13:43:14 +02:00
zurdi
4bd6a121d6 placeholder for config dictionaries 2024-07-09 10:35:07 +02:00