Commit Graph

87 Commits

Author SHA1 Message Date
Georges-Antoine Assi
6c88e098ba [ROMM-3232] Fix content_hash not updated 2026-04-07 21:48:51 -04:00
Georges-Antoine Assi
f107dc2752 changes from bot rview 2026-03-22 17:17:14 -04:00
nendo
4edb1710a5 fix: address review feedback on session handler and counter
- Restore NoResultFound behavior on update_session, complete_session,
  fail_session when row is missing (scalar returns None, old .one()
  raised -- silent None is a semantic regression)
- Remove redundant get_session call from _increment_session_counter;
  the atomic SQL increment is already a no-op on missing rows
- Log warning when passed session_id is not found in _sync_device
  instead of silently creating an orphan session
2026-03-16 10:59:49 +09:00
nendo
55638d15dc fix: address bugs, security issues, and convention violations in save-sync
- Fix broken path construction in FSSyncHandler: build_* methods now
  return relative paths; sync_watcher uses paths relative to sync base
  instead of CWD (was completely non-functional in production)
- Fix SSH connection leak in push-pull task: conn.close() now in finally
- Add log.warning for disabled SSH host key verification
- Fix race condition in session operation counter: use atomic SQL
  increment instead of read-then-write
- Extract _increment_session_counter helper, add exc_info to warnings
- Replace legacy session.query() with select() in sync_sessions_handler
- Fix orphaned session: trigger_push_pull now passes session_id to job
- Fix wasteful SSH download when no matched_save exists
- Fix BaseModel import collision in sync.py (pydantic -> project base)
- Fix ORM mutation in UserSchema.from_orm_with_request: set field on
  schema instance instead of mutating live ORM object
- Mask ssh_password and ssh_key_path in DeviceSchema API response
- Fix migration PostgreSQL compatibility: condition ON UPDATE clause
  on MySQL, drop enum in downgrade
- Rename copy-paste artifact rom_user_status_enum
2026-03-16 10:56:43 +09:00
Georges-Antoine Assi
29112b4ddc create device on login web 2026-03-15 11:25:39 -04:00
Georges-Antoine Assi
e6ddc5da11 bot attempt at save sync 2026-03-14 22:13:38 -04:00
Georges-Antoine Assi
ee8b55e6ef last set of changes 2026-03-07 09:56:17 -05:00
Georges-Antoine Assi
b3659a1226 changes from bot review 2026-03-07 08:58:42 -05:00
Georges-Antoine Assi
b030b98062 attempt to fix vuln reported in PR 2026-03-06 19:42:56 -05:00
Georges-Antoine Assi
827f787331 fix type issues 2026-03-06 17:17:11 -05:00
Georges-Antoine Assi
4bfd050a57 Merge branch 'master' into api-form-fields 2026-03-06 17:12:18 -05:00
Georges-Antoine Assi
6461078721 loosen rules around fetch matching screenshots 2026-02-19 10:18:56 -05:00
Georges-Antoine Assi
cef0ab0422 Update endpoints that use form data 2026-02-18 16:10:45 -05:00
Georges-Antoine Assi
6368afdb6f remove check completly 2026-02-16 15:17:03 -05:00
Georges-Antoine Assi
caa6d06646 [AIKIDO-13126609] Raise HTTP exception if device not found 2026-02-16 13:53:29 -05:00
nendo
e3642523f9 refactor(saves): simplify SaveSchema construction with model_validate
Add model_validator to SaveSchema that safely handles SQLAlchemy lazy
relationships by checking inspect(obj).unloaded before attribute access.
This allows direct use of model_validate(orm_obj) instead of manually
building a dict and excluding device_syncs.
2026-02-03 21:05:03 +09:00
nendo
132e0ad256 refactor(utils): extract to_utc function to utils/datetime.py
Move UTC datetime normalization to a dedicated utils module for
reusability across the codebase.
2026-02-03 20:07:47 +09:00
nendo
220d7531e7 refactor(saves): replace order_by_updated_at_desc with flexible order_by
Add order_by and order_dir parameters to get_saves() for flexible
sorting. Supports "updated_at" and "created_at" fields with "asc" or
"desc" direction (default: desc). Enables ascending order for pruning
scenarios.
2026-02-03 20:06:09 +09:00
nendo
a236123e4f feat(saves): add slot-based save sync with content hash deduplication
- Add device registration and save synchronization
- Implement slot-based save organization with datetime tagging
- Add conflict detection for multi-device sync scenarios
- Add content hash computation for save deduplication
- Support ZIP inner-file hashing for consistent deduplication
- Add confirm_download endpoint for sync state management
- Add overwrite parameter to bypass conflict checks
2026-01-31 21:57:22 +09:00
Georges-Antoine Assi
db6d35171e run fmt 2026-01-28 20:26:24 -05:00
Georges-Antoine Assi
24fef1139b Merge branch 'master' into feature/device-registration-save-sync 2026-01-28 19:42:57 -05:00
Georges-Antoine Assi
6b1eda0828 fix bot review 2026-01-18 23:35:03 -05:00
Georges-Antoine Assi
bddb7bd9f5 manual cleanup 2026-01-18 22:27:46 -05:00
Georges-Antoine Assi
3ccc14d4a2 add endpoints for identifiers 2026-01-18 22:17:37 -05:00
nendo
f0b2158390 Fix datetime comparison to normalize to UTC before comparing 2026-01-18 17:56:26 +09:00
nendo
26eccf0858 Fix endpoint scopes: downloaded/track/untrack require DEVICES_WRITE 2026-01-18 17:51:33 +09:00
nendo
36eec298d1 Add device-based save synchronization
Implement device registration and save sync tracking to enable
multi-device save management with conflict detection.

- Device CRUD endpoints (POST/GET/PUT/DELETE /api/devices)
- Save sync state tracking per device
- Conflict detection on upload (409 when device has stale sync)
- Download sync tracking (optimistic and confirmed modes)
- Track/untrack saves per device
- DEVICES_READ/WRITE scopes for authorization
2026-01-18 16:50:44 +09:00
Michael Manganiello
40326112bd misc: Improve API docs for Delete endpoints
Add more detailed descriptions for Delete endpoints.
2025-09-09 11:05:47 -03:00
Michael Manganiello
e4e3928d1b misc: Apply import sorting 2025-09-04 11:17:00 -03:00
Michael Manganiello
00d7815889 fix: Improve performance on asset screenshot retrieval
When retrieving the related screenshot for a `Save` or `State`, we were
retrieving a very heavy representation of the associated `Rom` object,
only to iterate through its screenshots to find the one we needed.

This change modifies the `Save` and `State` models to directly query the
`Screenshot` model, which is much faster and more efficient. The
`DBScreenshotsHandler` has been updated to include a new `filter` method
that will simplify building queries using SQLAlchemy, something we can
extend to other handlers in the future.

Fixes #1925.
2025-08-10 15:33:13 -03:00
Georges-Antoine Assi
51652d5084 make all path stuff async 2025-07-18 10:53:55 -04:00
Georges-Antoine Assi
aaf6741e93 Create safe filesystem handler 2025-07-17 12:30:57 -04:00
zurdi
cbc7b9c6cd feat: enhance logging for save uploads and improve missing firmware/platform indications in UI 2025-06-12 14:33:50 +00:00
zurdi
0670d2a695 refactor: enhance error messages with highlighted file names and platform details 2025-05-14 16:36:03 +00:00
zurdi
44bfcaa23c fix: fixed assets path for screenshots 2025-05-14 16:28:46 +00:00
zurdi
48e3e09dd1 fix: build file path 2025-05-14 15:11:39 +00:00
zurdi
5f94440c9d Merge branch 'master' into refactor/saves-states-path 2025-05-14 13:35:28 +00:00
zurdi
6f08912fc0 refactor: remove unnecessary logging highlights and improve log messages for clarity 2025-05-09 10:25:11 +00:00
zurdi
14761c2c83 refactor: enhance logging with highlighted output for improved readability 2025-05-09 09:05:59 +00:00
Georges-Antoine Assi
d087266937 also add to states endpoint 2025-05-04 21:00:56 -04:00
Samuel Nitzsche
df00fe21d4 when updating a save files also update the screenshot 2025-05-02 17:20:51 +02:00
zurdi
83cb0674c5 fix: include rom_id in file path building for saves and states 2025-04-25 16:54:36 +00:00
Georges-Antoine Assi
aa29f64ea2 fix assets test 2025-03-28 19:51:59 -04:00
Georges-Antoine Assi
d58691a79b always delete saves from fs + split delete dialogs 2025-03-27 23:37:42 -04:00
Georges-Antoine Assi
43f48899c9 add new endpoints to get some or all states and saves 2025-03-26 19:21:21 -04:00
Georges-Antoine Assi
c6d6a8100a wip refactor of save and state behaviour 2025-03-26 17:24:09 -04:00
Georges-Antoine Assi
7d54ef877b [HOTFIX] Remove single forward-slash endpoints 2025-02-11 13:48:24 -05:00
Michael Manganiello
70825830c4 misc: Set prefix and tags to API routers
Improve OpenAPI documentation by setting tags to each API router. Also,
set a prefix to each router to group the endpoints by their
functionality.
2025-02-09 11:31:13 -03:00
Georges-Antoine Assi
696a1c6122 Merge branch 'master' into rom-hashing-background-task 2025-01-15 21:51:23 -05:00
Michael Manganiello
865370ec13 misc: Move auth constants to separate file
This simplifies avoiding circular imports when trying to use auth
handlers.
2025-01-08 22:16:31 -03:00