refactor(server): extract the settings routes into routers/settings.py (R3) [needs device round-trip] - #863
Merged
Merged
Conversation
…y (R3) 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>
Contributor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (9)
📝 WalkthroughWalkthroughThe Settings API, settings export/import logic, and related helpers move from ChangesSettings router extraction
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant SettingsRouter
participant ConfigFile
participant PluginFiles
participant LibraryDB
Client->>SettingsRouter: Request settings or bundle operation
SettingsRouter->>ConfigFile: Load or atomically persist configuration
SettingsRouter->>PluginFiles: Export or stage plugin files
SettingsRouter->>LibraryDB: Snapshot or validate library database
SettingsRouter-->>Client: Return settings, bundle, or import status
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GET/POST /api/settings,/api/settings/reset, and the two-phase atomic export/import bundle (/api/settings/export|import) →lib/routers/settings.py, with their exclusive helpers (relpath-allowlist validator, the atomic writer, the library-DB snapshot + sqlite integrity gate, the config-type validator, the bundle schema).Bodies verbatim except
@app→@routerand 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 inserver.py— the scan + artist-links code share it — injected as a new seam callable).server.py: 5,539 → 4,478 (−1,061).Verification
pyflakesclean bar the pre-existingFile/safe_join/tuning_name/ET.pytest2397 passed — incl the 154 settings cases: the export→import round-trip, library-DB snapshot/restore, and the relpath-allowlist SSRF/traversal guards (retargeted onto the settings module).npm run lint0; Codex 0 findings.On-device round-trip to run before merge
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Refactor
Documentation