Commit Graph

620 Commits

Author SHA1 Message Date
Georges-Antoine Assi
b3a50021b7 run quick before hash scan 2024-08-12 11:57:47 -04:00
Georges-Antoine Assi
e24a3b86bd Hotfix scans when running HASH_SCAN 2024-08-12 11:37:49 -04:00
Georges-Antoine Assi
1ea1b326d3 move hashes to rom model 2024-08-11 22:38:22 -04:00
Georges-Antoine Assi
56037070fb only calc hashes exlpicit 2024-08-11 19:36:52 -04:00
Georges-Antoine Assi
a4e162e2c1 Merge branch 'master' into calc-file-hashes-roms 2024-08-11 19:07:06 -04:00
Georges-Antoine Assi
3e157eab1e Merge branch 'master' into fixup-sibling-speed 2024-08-09 22:55:52 -04:00
Georges-Antoine Assi
90e0e688b7 Merge branch 'master' into calc-file-hashes-roms 2024-08-09 11:36:50 -04:00
Michael Manganiello
b6aedfc902 fix: Allow access to Tinfoil feed when download auth is disabled
This matches the behavior of the Webrcade feed.
2024-08-09 09:54:59 -03:00
Georges-Antoine Assi
5f0577b900 more cleanup 2024-08-09 00:17:11 -04:00
Georges-Antoine Assi
3a1986f453 single lines for the virtual table 2024-08-08 23:27:31 -04:00
Georges-Antoine Assi
cd54d902a7 create database view for sibling roms 2024-08-08 22:25:50 -04:00
Michael Manganiello
95a66a182e misc: Improve typing for feed schemas
* Add typing for nested objects in Tinfoil and Webrcade feed schemas.
* Do not send Rom background and thumbnail, if not available.
* Correctly build URLs using `starlette` utils.
* Deprecate the `ROMM_HOST` setting, no longer needed.
* Fix FastAPI custom router to prefer routes without trailing slash.
* Fix Webrcade background URL pointing to gallery screenshot.
2024-08-07 22:56:16 -03:00
Michael Manganiello
8abbae4c02 misc: Make backend handle URLs with trailing slash
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] https://github.com/fastapi/fastapi/discussions/7298
2024-08-07 00:22:21 -03:00
Zurdi
ada7f5f837 Merge branch 'master' into fix/csrf-token 2024-08-05 20:16:52 +02:00
Georges-Antoine Assi
a53c0911d7 fix endpoint tests 2024-08-05 11:35:08 -04:00
zurdi
b9a68ad304 fix re-generate csrftoken when expired 2024-08-05 09:40:26 +02:00
Georges-Antoine Assi
b06b0f4f86 Merge pull request #1043 from rommapp/romm-1022
[ROMM-1022] Add button to show duplicates
2024-08-04 16:15:19 -04:00
Georges-Antoine Assi
8cd4cf1fe6 pull sibling roms from backend 2024-08-02 16:37:04 -04:00
Georges-Antoine Assi
29bb08e43c [ROMM-1018] Fix scanning selected roms 2024-07-28 20:13:44 -04:00
Michael Manganiello
16cb380cc0 misc: Use async interface for stream-zip
Replace use of synchronous `stream_zip` implementation, with
`async_stream_zip`. [1]

[1] https://stream-zip.docs.trade.gov.uk/async-interface/
2024-07-27 18:31:20 -03:00
Georges-Antoine Assi
2c2adb4112 Merge branch 'master' into calc-file-hashes-roms 2024-07-27 16:39:46 -04:00
Georges-Antoine Assi
9386ca9e4a changes from self-review 2024-07-27 16:31:32 -04:00
Georges-Antoine Assi
3a9cef24e0 get it all wokring 2024-07-27 13:30:52 -04:00
Georges-Antoine Assi
ecc021e824 Merge branch 'master' into calc-file-hashes-roms 2024-07-27 12:17:18 -04:00
Michael Manganiello
749e4d65c1 misc: Use PYTEST_VERSION variable to detect Pytest runs
Pytest v8.2 introduced the `PYTEST_VERSION` environment variable [1],
that can be used to check if code is running from within a pytest run.

This way, we can avoid checking the loaded `sys` modules.

[1] https://docs.pytest.org/en/stable/changelog.html#id57
2024-07-27 12:03:44 -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
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
efc0b75cdb Merge branch 'master' into calc-file-hashes-roms 2024-07-25 22:42:46 -04: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
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
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
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
52a96058c4 Merge branch 'master' into patch-1 2024-07-22 16:57:24 -04: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
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
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
Georges-Antoine Assi
2e91c440e3 Read into mem in chunks 2024-07-16 17:42:25 -04:00
Georges-Antoine Assi
2b2ff875ee Calculate hashes for rom files 2024-07-15 18:27:29 -04:00
Georges-Antoine Assi
6ec091e5da [ROMM-1003] Fix aborting mid-scan 2024-07-15 13:08:52 -04:00
zurdi
884e7a35ac fixed re-download lost covers 2024-07-11 08:47:59 +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
f7b14b43d6 fixed everything from trunk 2024-07-09 13:43:14 +02:00
Georges-Antoine Assi
5e3522ce40 Merge branch 'master' into prevent-mass-purge 2024-07-08 12:39:39 -04:00
zurdi
20fb8218aa fixes from trunk 2024-07-08 12:37:39 +02:00
zurdi
5de77e52ad Merge remote-tracking branch 'origin/master' into fix/fixes_from_testing 2024-07-08 11:57:07 +02:00
zurdi
1a3f74e8ac check username already exists on setup wizard 2024-07-08 11:56:10 +02:00
zurdi
ec58ea9511 fixed custom cover 2024-07-08 11:49:09 +02:00