Commit Graph

107 Commits

Author SHA1 Message Date
Georges-Antoine Assi
2cd9041e85 Merge branch 'master' into openid-connect 2024-12-09 19:25:44 -05:00
Georges-Antoine Assi
b7dac4743a Merge branch 'master' into openid-connect 2024-12-07 22:19:24 -05:00
Michael Manganiello
743ecd83e7 misc: Fix some typing issues 2024-12-07 12:29:45 -03:00
zurdi
5bef403b83 upgrade fastapi to v0.115.6 2024-12-04 01:39:03 +00:00
dependabot[bot]
f61ae45ec4 build(deps): Bump python-multipart from 0.0.9 to 0.0.18
Bumps [python-multipart](https://github.com/Kludex/python-multipart) from 0.0.9 to 0.0.18.
- [Release notes](https://github.com/Kludex/python-multipart/releases)
- [Changelog](https://github.com/Kludex/python-multipart/blob/master/CHANGELOG.md)
- [Commits](https://github.com/Kludex/python-multipart/compare/0.0.9...0.0.18)

---
updated-dependencies:
- dependency-name: python-multipart
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-12-02 22:37:26 +00:00
zurdi
a51dd03e1a Added full offline support and configurable logging level and API requests debug logs 2024-11-27 17:12:13 +00:00
Georges-Antoine Assi
3a91b7ba54 Merge branch 'master' into openid-connect 2024-11-26 19:52:18 -05: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
4bb5cb5149 misc: Initial addition of IGDB typehints
The short-term goal is to completely typehint the IGDB API responses. This
first change adds the base structures and enums RomM currently uses.

The `ExpandableField` type will allow us to model the expansion
mechanism the IGDB API provides, where a field can include either an ID,
or the full nested structure.
2024-10-27 00:02:01 -03:00
Michael Manganiello
b81fbc5820 fix: Improve handling of Redis URL
This change replaces the creation of Redis URL, from a simple string
interpolation, to using `yarl.URL`. The main benefit, besides not
forgetting to set all five different variables on every Redis client
initialization, is that user credentials are correctly URL-encoded, if
present.

Up until now, if a password had special characters, it could break the
generated URL.

This change also introduces support for a `REDIS_SSL` setting, which
allows the user to specify if the Redis connection should use SSL or not.
2024-10-11 21:41:19 -03:00
Michael Manganiello
149098fb31 fix: Improve memory usage during 7zip decompression
This change improves memory usage, by only keeping a single archive's
member file in memory at a time during 7zip decompression.

The `py7zr` library does not support streaming decompression yet, so
this change is the best we can do for now.

Potential fix for #1211, but it won't improve memory usage for
single-file 7zip archives.
2024-10-06 20:18:49 -03:00
Georges-Antoine Assi
00c8771e22 [ROMM0-1155] Patch zipfil + catch more 7zip errors 2024-09-01 21:58:22 -04:00
Michael Manganiello
0fad8ac282 feat: Use nginx mod_zip to generate multi-file zip downloads
This change installs and configures the `mod_zip` nginx module [1],
which allows nginx to stream ZIP files directly.

It includes a workaround needed to correctly calculate CRC-32 values for
included files, by including a new `server` section listening at port
8081, only used for the file requests to be upstream subrequests that
correctly trigger the CRC-32 calculation logic.

Also, to be able to provide a `m3u` file generated on the fly, we add a
`/decode` endpoint fully implemented in nginx using NJS, which receives
a `value` URL param, and decodes it using base64. The decoded value is
returned as the response.

That way, the contents of the `m3u` file is base64-encoded, and set as
part of the response, for `mod_zip` to include it in the ZIP file.

[1] https://github.com/evanmiller/mod_zip
2024-08-20 22:39:33 -03:00
Georges-Antoine Assi
a071c0a487 actual real upload streaming 2024-08-17 11:50:14 -04:00
Michael Manganiello
0fdbbe4625 misc: Upgrade Python to v3.12 and Alpine to v3.20
Included upgrades:
* Python: v3.12
* Alpine: v3.20 (which uses Python 3.12)
* nginx: v1.27.1
2024-08-15 20:14:32 -03:00
Georges-Antoine Assi
90e0e688b7 Merge branch 'master' into calc-file-hashes-roms 2024-08-09 11:36:50 -04:00
Georges-Antoine Assi
0fae870837 start work with fake openid add for testing 2024-08-04 00:41:34 -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
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
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
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
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
77afe55625 add support for extracting content in compressed files 2024-07-18 21:50:24 -04:00
Georges-Antoine Assi
591e41a4d5 start checking for specific file exts 2024-07-18 20:51:48 -04:00
zurdi
f7b14b43d6 fixed everything from trunk 2024-07-09 13:43:14 +02:00
zurdi
375898221d added ipykernel to dev dependencies 2024-06-27 12:50:43 +02:00
Michael Manganiello
b99ededced misc: Migrate to SQLAlchemy declarative models
This change applies the guided migration process recommended by
SQLAlchemy [1], up to step 4, to have declarative ORM models that better
support Python typing.

The change was tested by running `alembic check`, which does not find
any schema changes.

Errors reported by `mypy` go down to 170, from the original 223 in the
current `master` commit.

[1] https://docs.sqlalchemy.org/en/20/changelog/whatsnew_20.html#migrating-an-existing-mapping
2024-06-25 23:03:20 -03:00
Michael Manganiello
707b2ec6bd fix: Remove abandoned dependency aioredis
`aioredis` is abandoned, and has been replaced by `redis.asyncio`.

Currently, the project doesn't use `aioredis` directly, but depends on
it for `socketio.AsyncRedisManager`. This change is safe, as `socketio`
has been prioritizing `redis.asyncio` over `aioredis` since `v5.6.0` [1].

[1] 0e7691b776
2024-06-23 18:12:38 -03:00
Michael Manganiello
ed635d69cc misc: Move fakeredis to test dependencies
`fakeredis` is only needed when running tests, so we can move it to the
`test` dependency group.
2024-06-23 11:10:25 -03:00
Georges-Antoine Assi
9b62641d55 Merge branch 'master' into trunk-io 2024-05-31 18:42:43 -04:00
Georges-Antoine Assi
95412760be Remove pagination from roms endpoints 2024-05-31 12:15:52 -04:00
Zurdi
44f10a560c Solve merge into release conflicts 2024-05-31 16:46:35 +02:00
Georges-Antoine Assi
2b60402a04 start fixing mypy issues 2024-05-21 19:22:14 -04:00
Georges-Antoine Assi
2a980a04e6 last bits of fixes 2024-05-21 17:52:13 -04:00
Georges-Antoine Assi
a7cf0d389a run trunk format on all files 2024-05-21 10:18:13 -04:00
dependabot[bot]
ee28b7ee8d ---
updated-dependencies:
- dependency-name: requests
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-21 05:33:54 +00:00
Georges-Antoine Assi
b1a14a6f22 add authlib jose 2024-05-12 21:33:53 -04:00
Georges-Antoine Assi
5bce52f9d4 drop numpy and jose 2024-05-12 21:13:41 -04:00
dependabot[bot]
3c5bff39fe Bump gunicorn from 21.2.0 to 22.0.0
Bumps [gunicorn](https://github.com/benoitc/gunicorn) from 21.2.0 to 22.0.0.
- [Release notes](https://github.com/benoitc/gunicorn/releases)
- [Commits](https://github.com/benoitc/gunicorn/compare/21.2.0...22.0.0)

---
updated-dependencies:
- dependency-name: gunicorn
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-17 02:51:23 +00:00
dependabot[bot]
60f02eec98 Bump pillow from 10.2.0 to 10.3.0
Bumps [pillow](https://github.com/python-pillow/Pillow) from 10.2.0 to 10.3.0.
- [Release notes](https://github.com/python-pillow/Pillow/releases)
- [Changelog](https://github.com/python-pillow/Pillow/blob/main/CHANGES.rst)
- [Commits](https://github.com/python-pillow/Pillow/compare/10.2.0...10.3.0)

---
updated-dependencies:
- dependency-name: pillow
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-03 16:47:54 +00:00
Georges-Antoine Assi
82fa7ae025 add yarl explicit dep 2024-03-26 21:17:40 -04:00
Georges-Antoine Assi
fd196165b8 add fake redis for tests 2024-03-26 20:37:38 -04:00
Georges-Antoine Assi
770313c1f1 hset all in cache for quick access 2024-03-26 19:03:42 -04:00
Psych0D0g
8f5536c69b switch to gunicorn for handling backend app 2024-03-25 21:56:19 +01:00
zurdi
b2392d0acc replaced old zurdi15/romm url to rommapp/romm 2024-03-25 02:49:08 +01:00
Georges-Antoine Assi
6bee52cc98 implement session middlware 2024-03-17 11:37:37 -04:00