Commit Graph

326 Commits

Author SHA1 Message Date
Georges-Antoine Assi
dea606ad80 Merge pull request #2261 from rommapp/hash-largest-file
Always hash the largest file in compressed multi file roms
2025-08-13 13:21:59 -05:00
Georges-Antoine Assi
4936ea5121 changes from code review 2025-08-13 14:11:33 -04:00
Georges-Antoine Assi
8fb4769776 changes from code review 2025-08-13 14:03:45 -04:00
Georges-Antoine Assi
81a04e4ab4 Always hash the largest file in compressed multi file roms 2025-08-13 13:43:07 -04:00
Michael Manganiello
80291f4be1 misc: Move cache initialization to startup script
Guarantee that cache is initialized during startup, and only once,
instead of every time a `MetadataHandler` object is instantiated.

Also, improve logic to determine `fixtures` paths.
2025-08-13 12:26:15 -03:00
Georges-Antoine Assi
d005dba90b fix a bunch of shit 2025-08-09 11:16:12 -04: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
Georges-Antoine Assi
c47be7240b changs from bot review 2025-08-07 18:15:49 -04:00
Georges-Antoine Assi
9e37d87610 fix complex game names 2025-08-07 18:02:04 -04:00
Georges-Antoine Assi
b247a5c5bb small tweaks 2025-08-07 17:39:57 -04:00
Georges-Antoine Assi
926fe26fd9 [exp] use cli 7z to cacl hash files 2025-08-07 13:12:32 -04:00
Michael Manganiello
097818d560 misc: Replace emoji dependency with constants
The `emoji` library has been removed, in favor of using constants for
the few emojis used in the codebase. This reduces memory usage, and
avoids calling `emojize` for Python to discover where to replace emojis
in pre-defined strings.
2025-08-07 09:50:14 -03:00
Georges-Antoine Assi
9fd1adbbfb fixup icon names 2025-07-24 23:20:07 -04:00
Georges-Antoine Assi
59a2e5d5aa move away from explicit LIST use 2025-07-24 16:41:17 -04:00
Georges-Antoine Assi
1bb33be803 more work migrating slugs 2025-07-24 09:30:57 -04:00
Georges-Antoine Assi
6ad0b3f5d1 Only run slug_lower once 2025-07-21 17:29:01 -04:00
Georges-Antoine Assi
3372b754fe Group generated platforms by slug and filter by name 2025-07-21 17:22:16 -04:00
Georges-Antoine Assi
51652d5084 make all path stuff async 2025-07-18 10:53:55 -04:00
Georges-Antoine Assi
cfe848e14a load all igsb platform data into app 2025-07-13 14:59:54 -04:00
Georges-Antoine Assi
b11845242b use images for suported platforms 2025-07-09 16:10:37 -04:00
Georges-Antoine Assi
75b6ca9277 fix generating supported platforms 2025-07-09 15:57:48 -04:00
Georges-Antoine Assi
837d36375d Fix metadata issues in heasheous handler 2025-07-09 09:14:41 -04:00
Georges-Antoine Assi
e8f8f1621c complete migration to uv 2025-07-04 09:54:04 -04:00
Michael Manganiello
f96adeeaee misc: Upgrade to Python 3.13
Small changes to upgrade Python to version 3.13, and fixes based on a
`pyupgrade` run using the `--py313-plus` flag.
2025-07-03 23:37:00 -03:00
Georges-Antoine Assi
6d16ca41cc have cursor fix small bugs 2025-07-03 09:46:39 -04:00
Michael Manganiello
252722e3bc misc: Apply pyupgrade changes for Python 3.12 compatibility
Command applied:
```
find ./backend/ -type f -name "*.py" -exec pyupgrade --py312-plus {} \;
```
2025-06-29 12:27:16 -03:00
Georges-Antoine Assi
0609747c6c finish migration platforms 2025-06-16 14:13:23 -04:00
Georges-Antoine Assi
2e677decea Merge branch 'master' into romm-403 2025-06-09 17:20:17 -04:00
Michael Manganiello
fe1a9ce2a7 fix: Use aiohttp for RetroAchievements API calls
This change replaces the `httpx` client with `aiohttp` for the
RetroAchievements API service.

The main reason for this change is that `httpx` has an unavoidable log
line with `INFO` level, which includes the request full URL, containing
the user's API key.

`httpx` has had an
[open discussion](https://github.com/encode/httpx/discussions/2765)
regarding this security issue for almost two years.

The change to `aiohttp` is painless, and would allow us to migrate more
of the codebase to it in the future, to avoid leaking sensitive
information in logs.
2025-06-09 09:59:56 -03:00
Georges-Antoine Assi
7627380cee fix tests and launchbox 2025-05-23 20:01:07 -04:00
Georges-Antoine Assi
32988a8c93 fix IDs and generate platforms 2025-05-23 14:50:56 -04:00
Georges-Antoine Assi
fd705e41ce add and store fake launchbox IDs 2025-05-23 14:13:19 -04:00
Georges-Antoine Assi
fcdfcadf61 [HOTFIX] Update content-disposition headers 2025-04-03 13:13:25 -04:00
Zurdi
881a1d158d Merge pull request #1523 from jamiecounsell/fix/mysql-json-contains
Fix MySQL json_contains Error by Converting Non-String Values to JSON Strings
2025-02-02 00:19:12 +01:00
Michael Manganiello
72a0d2b12b Add isort fixes 2025-02-01 20:13:59 -03:00
Jamie Counsell
570cb6efdf refactor based on PR feedback 2025-02-01 15:20:42 -05:00
Jamie Counsell
835def23cc coerse JSON contains args to str when using mysql 2025-01-21 13:54:04 -05:00
Michael Manganiello
b298da86d5 Merge pull request #1474 from rommapp/fix/socketio-json-dumps
fix: SocketIO JSON dumps with sane defaults
2025-01-12 02:34:09 -03:00
Michael Manganiello
d837070ad0 fix: SocketIO JSON dumps with sane defaults
Similar to how `engineio` provides a JSON-compatible module, this change
adds a custom JSON encoder with support for additional types.

Changing SocketIO's JSON module fixes the encoding issue when the
scanning process tried to send a datetime, failing and the frontend not
displaying the scanned game (commonly, when it had sibling games)
2025-01-12 00:41:15 -03:00
Michael Manganiello
6b9ff574f8 misc: Add typehints to safe type conversion functions 2025-01-11 23:18:09 -03:00
Georges-Antoine Assi
aacad9c697 [HOTFIX] Safe cast values to int for first_release_date 2025-01-11 19:37:39 -05:00
Georges-Antoine Assi
b4b0d3fb85 [HOTFIX] Safe cast values to float 2025-01-11 19:22:31 -05:00
Michael Manganiello
7825bce7b8 fix: Use proper JSON contains function for PostgreSQL
Fix `json_array_contains_value` function to use the `@>` operator for
checking if a JSON array contains a value in PostgreSQL. This is
necessary because the `has_key` function only works for string values.

Also, remove `get_rom_collections` method, as it was doing the same
thing as `get_collections_by_rom_id`.

Fixes #1441.
2025-01-08 21:07:01 -03:00
Michael Manganiello
3f4a36a5ce feat: PostgreSQL compatibility
This change introduces PostgreSQL compatibility, by implementing the
following changes:

* Use `JSONB` instead of `JSON` for PostgreSQL databases. This is
  achieved by creating a custom `CustomJSON` type that uses `JSONB` on
  PostgreSQL and `JSON` on other databases, leveraging the variant
  mechanism of SQLAlchemy.
* Add `is_postgresql` function to check if the current database is
  PostgreSQL. Commonly used for migrations, but can be used to determine
  how to build queries based on the database engine.
* Add `json_array_contains_value` function to check if a JSON array
  includes a specific value. This function is needed as it's
  engine-specific.

Support for PostgreSQL is on a best-effort basis, and it relies on the
community for continued support and testing. The project's main database
is MariaDB.

Closes #667.
2024-12-31 12:36:33 -03:00
Michael Manganiello
7dc7eea34d feat: Initial Sentry support
This change initializes the Sentry SDK, which enables error tracking
when the `SENTRY_DSN` environment variable is set.

Drop-in alternatives to Sentry are also supported, like GlitchTip.
2024-12-27 17:03:45 -03:00
Michael Manganiello
3eb9d902d6 misc: Remove print leftover in CallbackIO class 2024-12-16 22:50:28 -03:00
Michael Manganiello
477d9b1744 feat: Add streaming support for 7zip hashing
At the moment, 7zip files are generating memory issues and even OOM
errors on user installations. This is because the current stable release
of `py7zr` does not support decompression streaming, and RomM needs to
decompress the each 7zip file in the library into memory to be able to
calculate hashes.

This change introduces a `py7zr` fork I created to have a stable commit
SHA to refer to in case upstream gets any forced pushes. It includes the
contents of the pull request the `py7zr` creator is working on to
support decompression streaming [1].

The way decompression streaming is implemented in `py7zr` is different
than the other compression utilities. Instead of being able to provide a
`bytes` iterator, we need to provide a `Py7zIO` implementation that
will call a callback on each read and write operation.

[1] https://github.com/miurahr/py7zr/pull/620
2024-11-08 21:31:11 -03:00
Michael Manganiello
60ff832663 fix: Escape URLs when files are served by nginx
When serving files using the `X-Accel-Redirect` header in nginx, the
header values must be URL-encoded. Otherwise, nginx will not be able
to serve the files if they contain special characters.

This commit adds a new `FileRedirectResponse` class to the `utils.nginx`
module, to simplify the creation of responses that serve files using the
`X-Accel-Redirect` header.

Fixes #1212, #1223.
2024-10-06 13:29:42 -03:00
Georges-Antoine Assi
38d5ec13a5 compile regexes 2024-08-26 13:02:50 -04:00
Georges-Antoine Assi
c8b8bcabc8 Replace illegal fs chars in filenames 2024-08-21 22:26:56 -04:00