Commit Graph

43 Commits

Author SHA1 Message Date
Georges-Antoine Assi
787bbba2b4 refactor(tasks): give every enqueue one home
Scheduling moved onto RQ, which left the task catalog with two identity
schemes: the registry key a job payload now carries, and the dotted func
path each PeriodicTask still declared. Nothing read the latter, so it is
gone, along with the test that guarded paths no payload names.

Four sites built the same enqueue by hand and had already drifted: the
startup backfills passed the global timeout and no result_ttl, so an
auto-enqueued conversion fell out of the task list after RQ's default
500s while the same task triggered by an admin lived for TASK_RESULT_TTL.
They now go through enqueue_task, which derives timeout, ttl and meta
from the task itself.

Scan discovery paid a Redis round trip per queued job to re-read a status
the fetch already carried, and the stale sweep read every delayed job to
find the few past due. Both now ask Redis once.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-02 21:03:30 -04:00
Sam Dornan
4e59217275 refactor(tasks): schedule with RQ instead of rq-scheduler
rq-scheduler has one release since 2023, 109 open issues, and RomM ran a
fork of it for Redis username and SSL options that upstream never took.
Everything it was here for now ships with RQ.

Its two failure modes were the reason for the workarounds in 9e9f59c04.
It reads a job's function name before taking the job out of its registry,
so one unreadable job stalls it for good; RQ's scheduler removes every id
it looked at whether or not the job could be read. And cancelling a
delayed job needed both `Scheduler.cancel` and `Job.cancel`, because the
first left the status alone and the second left the registry entry, which
the scheduler then queued anyway; `Job.cancel` on its own now clears the
scheduled registry.

Delayed jobs, which is how the watcher defers a rescan, go onto the queue
with `Queue.enqueue_in` and are released by the worker running with
`--with-scheduler`. Periodic tasks are declared in `tasks/cron_config.py`
and loaded by an `rq cron` process, replacing `rqscheduler`. A task is
registered only when it is enabled and has a cron string, so the
schedule-then-unschedule dance around the env toggles is gone, and with
it `PeriodicTask.init/schedule/unschedule`.

Jobs are enqueued by task name through `run_task_by_name`, resolved
against a catalog in `tasks/registry.py`. Nothing pickles a task instance
into Redis any more, which is what made a payload unreadable across
upgrades in the first place. The catalog also gives the tasks endpoint
one home for what a task is, rather than a list of its own.

Scan discovery keys off the type a job carries rather than the scheduled
rescan's function name, since every task now shares one entry point. That
also drops SCAN_LIBRARY_TASK_FUNC, which only existed to name a function
across an import cycle.

The watcher's dedupe worked on `job.args[0]` while scans are enqueued with
keyword arguments, so it never matched and every filesystem change
scheduled another scan. It reads `platform_ids` from the payload now, and
deliberately ignores a scan already running: that one may have walked past
the folder that just changed.

Startup clears what the old scheduler left in Redis, once.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-02 15:02:04 -05:00
nendo
70e583b9a0 Add music favorites and playlists API
Spotify-style library features for soundtrack tracks: per-user favorites
(liked songs) and user-owned playlists with manual ordering and optional
public read-only sharing.

Track references are stored as (rom_id, md5_hash) rather than rom_file_id:
scans purge and re-insert rom_files rows, so file ids churn while rom ids
and content hashes are stable. Entries survive rescans and renames, and
resolve to the current file at query time; entries whose content is gone
are omitted from listings until the file returns.

To make the content hash reliably present, soundtrack audio files are now
always hashed individually during scans (including NON_HASHABLE_PLATFORMS
and SKIP_HASH_CALCULATION, whose file-size concerns don't apply to audio),
and soundtrack uploads compute crc/md5/sha1 on write. Existing libraries
backfill via a HASHES scan; adding an unhashed track returns 400.

New playlists.read/playlists.write scopes are wired through the granular
permission system (PermEntity.PLAYLISTS); the migration mirrors every
group's collections grants onto the playlists entity so existing groups
keep working without admin intervention.

Endpoints under /api/music: favorites GET/POST/DELETE, is_favorite and
md5_hash on track rows, playlists CRUD, playlist tracks GET/POST/DELETE
and PUT /tracks/order.
2026-07-23 15:32:32 +09:00
Georges-Antoine Assi
661a5504d7 find a couple more uses 2026-02-09 17:26:21 -05:00
Georges-Antoine Assi
6cbf9bcbc2 run trunk fmt 2025-11-21 19:20:38 -05:00
Kieran Wood
7b8e6f1657 Added gemini-code-assist suggestions 2025-11-21 13:37:57 -07:00
Kieran Wood
0e4b7fd160 Fixed link to documentation in filestructure error 2025-11-21 13:25:28 -07:00
Georges-Antoine Assi
19b5a83261 Use default config values when config.yml not mount + show warning 2025-09-19 09:17:59 -04:00
Michael Manganiello
e4e3928d1b misc: Apply import sorting 2025-09-04 11:17:00 -03:00
Georges-Antoine Assi
51652d5084 make all path stuff async 2025-07-18 10:53:55 -04:00
Michael Manganiello
9ba787f6d1 fix: Remove critical log messages for 403 and 404 exceptions
These critical log messages are unnecessary and can clutter the logs,
based on user requests. This is even more notorious when RomM is
integrated to an error tracking system like Sentry.
2025-06-06 21:40:31 -03:00
zurdi
0670d2a695 refactor: enhance error messages with highlighted file names and platform details 2025-05-14 16:36:03 +00:00
zurdi
30a0be2c4c Merge branch 'master' into HEAD 2025-04-10 22:56:55 +00:00
zurdi
2a5bf1ab5b Add SGDBInvalidAPIKeyException for handling invalid API key errors 2025-04-01 09:52:33 +00:00
Georges-Antoine Assi
db26248f04 Remove disabled login check from login endpoint 2025-03-21 14:58:47 -04:00
Georges-Antoine Assi
04c31374af disable login endpoint as wel 2025-01-07 17:28:13 -05:00
Georges-Antoine Assi
34d49e6494 changes from self review 2024-12-13 11:33:39 -05:00
Georges-Antoine Assi
3abf50b056 changes from self review 2024-11-27 23:28:54 -05:00
Georges-Antoine Assi
bc5c2e45f3 wokring oidc setup with authentik 2024-11-26 23:57:15 -05:00
SaraVieira
9b298d46eb use env & reuse request 2024-09-10 21:00:20 +01:00
SaraVieira
2d39949aa0 show info on frontend 2024-09-08 16:35:30 +01: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
Zurdi
23e0a064ab added update collection endpoint 2024-07-02 23:34:50 +02:00
Zurdi
857573e607 Merge remote-tracking branch 'origin/master' into feature/collections 2024-07-02 17:53:35 +02:00
Zurdi
4a413db4c5 fixes from PR review 2024-07-02 17:49:48 +02:00
Zurdi
cc9e05f668 collections migration added 2024-07-01 23:47:15 +02:00
zurdi
15f7522da5 rom db hanlder refactor to adapt to user_rom_props 2024-07-01 15:30:14 +02:00
Georges-Antoine Assi
880345f20c ruff-only pre-commit 2024-05-18 12:05:57 -04:00
Georges-Antoine Assi
eca1eb1136 model and scanning 2024-05-01 15:27:16 -04:00
zurdi
d3864ff02b create platform if not exists when adding roms fixed 2024-04-11 01:39:58 +02:00
zurdi
df047cc5e9 upload roms button in drawer added 2024-04-08 18:31:02 +02:00
Georges-Antoine Assi
2447c95ea6 update links to github 2024-03-23 10:11:55 -04:00
Zurdi
f1c5e02c32 config errors management improved 2024-01-18 11:46:12 +01:00
Zurdi
4b9e76f550 backend structure refactor 2024-01-12 23:44:27 +01:00
Georges-Antoine Assi
5762270f62 Merge branch 'master' into romm-55 2024-01-09 13:06:51 -05:00
Zurdi
eea7e41940 docstrings added to endpoints + organized imports + formatted code 2024-01-09 16:22:31 +01:00
Georges-Antoine Assi
cdafd680a0 Merge branch 'master' into romm-55 2024-01-05 15:38:05 -05:00
Zurdi
78152d91ee added backend endpoint to remove a platform 2024-01-05 11:48:56 +01:00
Georges-Antoine Assi
d4d929b29b Get upload and delete working 2023-11-23 20:47:27 -05:00
Georges-Antoine Assi
3965ca1997 Add basic auth + fix tests and typing 2023-08-23 11:21:01 -04:00
zurdi
f4f936f624 user avatar and enable/disable user support added 2023-08-23 14:16:31 +02:00
zurdi
5c0b6ea692 disabled browser login prompt in 401 responses 2023-08-18 10:44:01 +02:00
zurdi
3bc15bcbd3 extracted credentials exceptions in separated file 2023-08-18 09:05:54 +02:00