Commit Graph

4111 Commits

Author SHA1 Message Date
Michael Manganiello
9319081ff6 fix: Return early if IGDB finds an exact match
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.
2024-07-27 00:53:27 -03:00
Michael Manganiello
9b52a4b813 Merge pull request #1030 from rommapp/fix/enable-async-rules-ruff
fix: Enable flake8-async rules in ruff and fix warnings
2024-07-27 00:41:32 -03:00
Michael Manganiello
d1fda9081f fix: Add missing awaits on read/write for async opened files 2024-07-27 00:38:05 -03:00
Michael Manganiello
c5b150c1eb fix: Enable flake8-async rules in ruff and fix warnings
`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
2024-07-26 21:40:46 -03:00
Michael Manganiello
146c26cc53 Merge pull request #1023 from rommapp/misc/migrate-igdb-handler-to-async
misc: Migrate IGDBBaseHandler to async
2024-07-26 21:25:46 -03:00
Michael Manganiello
96699a2f1b fix: Catch ProtocolError when writing screenshots/covers 2024-07-26 21:19:18 -03:00
Michael Manganiello
aced1f1ff2 misc: Migrate IGDBBaseHandler to async
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.
2024-07-26 21:19:01 -03:00
Georges-Antoine Assi
141edf9d2e Merge pull request #1028 from rommapp/share-public-collections
Public collections
2024-07-25 22:38:21 -04:00
Georges-Antoine Assi
ad3a588631 filter collections for each user 2024-07-25 19:53:44 -04:00
Georges-Antoine Assi
fafd48586c Merge pull request #1026 from rommapp/romm-1025
[ROMM-1025] Replace game-and-watch with g-and-w
2024-07-25 17:41:09 -04:00
Zurdi
38a500f577 Merge branch 'master' into romm-1025 2024-07-25 21:35:18 +02:00
Georges-Antoine Assi
7555c0607a [ROMM-1025] Replace game-and-watch with g-and-w 2024-07-25 14:26:06 -04:00
Michael Manganiello
377d460623 Merge pull request #1024 from rommapp/misc/refactor-scan-process
misc: Refactor scan process by splitting single function
2024-07-25 15:05:15 -03:00
Georges-Antoine Assi
92b23656aa start making collecitons public 2024-07-25 13:49:43 -04:00
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