refactor(server): extract the media/file-serving routes into routers/media.py (R3) - #869
Merged
Merged
Conversation
…media.py (R3)
Song audio (/audio/{f}), the local-audio-path resolver (/api/audio-local-path),
and raw sloppak-member serving (/api/sloppak/{f}/file/{rel}) — plus the shared
_resolve_sloppak_local_file helper — move to lib/routers/media.py. Bodies verbatim
except @app->@router and the cache/static path seams (AUDIO_CACHE_DIR->
appstate.audio_cache_dir, STATIC_DIR->appstate.static_dir, SLOPPAK_CACHE_DIR->
appstate.sloppak_cache_dir — all already in the seam). No new slots.
The two test fixtures that redirect STATIC_DIR to a temp dir now also patch
appstate.static_dir (the moved routes read the seam, not server's global).
server.py: 2,638 -> 2,507 (-131).
Verified: pyflakes clean; route set identical (143), all unique-path (no
catch-all, no shadowing); full pytest 2395 passed (the audio-local-path +
sloppak-file-traversal cases). eslint 0. Boot smoke: /audio, /api/sloppak/{}/file
serve 404 for unknown, 0 tracebacks.
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 (6)
📝 WalkthroughWalkthroughMedia and audio file-serving routes are extracted from ChangesMedia router extraction
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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.
Song audio (
/audio/{f}), the local-audio-path resolver (/api/audio-local-path), and raw sloppak-member serving (/api/sloppak/{f}/file/{rel}) — plus the shared_resolve_sloppak_local_file— →lib/routers/media.py.Bodies verbatim except
@app→@routerand the cache/static path seams (AUDIO_CACHE_DIR→appstate.audio_cache_dir,STATIC_DIR→appstate.static_dir,SLOPPAK_CACHE_DIR→appstate.sloppak_cache_dir— all already in the seam). No new slots. The two test fixtures that redirectSTATIC_DIRto a temp dir now also patchappstate.static_dir(the moved routes read the seam).server.py: 2,638 → 2,507 (−131).Verification
pyflakesclean; route set identical (143), all unique-path (no catch-all, no shadowing).pytest2395 passed (the audio-local-path + sloppak-file-traversal cases).npm run lint0; Codex 0 findings./audio,/api/sloppak/{}/fileserve 404 for unknown, 0 tracebacks.🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes
Documentation