mirror of
https://github.com/got-feedBack/feedBack.git
synced 2026-08-11 03:09:57 +00:00
refactor(server): extract the settings routes into routers/settings.py (R3) (#863)
GET/POST /api/settings, /api/settings/reset, and the two-phase atomic export/import bundle (/api/settings/export|import) move to lib/routers/settings.py with their exclusive helpers (the relpath allowlist validator, the atomic writer, the library-DB snapshot + sqlite integrity gate, the config-type validator, the bundle schema). Bodies verbatim except @app->@router and the seam reads: meta_db->appstate.meta_db, CONFIG_DIR->appstate.config_dir, _running_version->appstate.running_version(), and _default_settings-> appstate.default_settings (the canonical defaults builder stays in server.py — the scan + artist-links code share it — and is injected as a new seam callable). server.py: 5,539 -> 4,478 (-1,061). Verified: pyflakes clean (bar the pre-existing File/safe_join/tuning_name/ET); route table IDENTICAL (143); full pytest 2397 passed (154 settings cases incl the export→import round-trip + library-DB snapshot/restore + relpath-allowlist SSRF/ traversal guards, retargeted onto the settings module). eslint 0. BEHAVIORAL — needs an on-device settings export→import round-trip sign-off before merge (do not merge on green CI alone). Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
73127d5416
commit
7258e1066a
@@ -10,6 +10,7 @@ shadow the config.json dlc_dir fallback.
|
||||
"""
|
||||
|
||||
import importlib
|
||||
from routers import settings as settings_router
|
||||
import json
|
||||
import sys
|
||||
|
||||
@@ -32,13 +33,13 @@ class _DirectSettingsClient:
|
||||
def get(self, path):
|
||||
if path != "/api/settings":
|
||||
raise ValueError(f"unsupported path: {path}")
|
||||
return _DirectResponse(self._server.get_settings())
|
||||
return _DirectResponse(settings_router.get_settings())
|
||||
|
||||
def post(self, path, json):
|
||||
if path == "/api/settings":
|
||||
return _DirectResponse(self._server.save_settings(json))
|
||||
return _DirectResponse(settings_router.save_settings(json))
|
||||
if path == "/api/settings/reset":
|
||||
return _DirectResponse(self._server.reset_settings(json))
|
||||
return _DirectResponse(settings_router.reset_settings(json))
|
||||
raise ValueError(f"unsupported path: {path}")
|
||||
|
||||
def close(self):
|
||||
@@ -643,7 +644,7 @@ def test_achievements_enabled_persists_and_validates(api_client, tmp_path):
|
||||
|
||||
def test_achievements_enabled_is_resettable(server_module):
|
||||
"""The flag is in the resettable allow-list so a Reset clears it to default."""
|
||||
assert "achievements_enabled" in server_module._RESETTABLE_SETTINGS_KEYS
|
||||
assert "achievements_enabled" in settings_router._RESETTABLE_SETTINGS_KEYS
|
||||
|
||||
|
||||
def test_skip_startup_tasks_drives_startup_to_complete(api_client):
|
||||
|
||||
Reference in New Issue
Block a user