Add admin endpoint to stream list of stored filenames#51
Open
hauxir wants to merge 2 commits into
Open
Conversation
GET /admin/files streams one filename per line from IMAGES_DIR using os.scandir, so memory stays flat even for very large stores. Gated by the existing Bearer API key. Supports optional ?prefix= and ?limit=. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Review Summary by QodoAdd admin endpoint to stream list of stored filenames
WalkthroughsDescription• Adds GET /admin/files endpoint to stream stored filenames • Uses os.scandir for memory-efficient streaming regardless of store size • Supports optional ?prefix= filtering and ?limit= sampling parameters • Secured with existing Bearer token authentication via check_auth Diagramflowchart LR
A["GET /admin/files<br/>endpoint"] -->|"scandir<br/>IMAGES_DIR"| B["Stream filenames<br/>one per line"]
B -->|"optional<br/>?prefix="| C["Filter by prefix"]
B -->|"optional<br/>?limit="| D["Limit results"]
A -->|"Bearer token"| E["check_auth<br/>validation"]
File Changes1. app/app.py
|
Code Review by Qodo
1.
|
Filenames containing newline or carriage-return characters would have split across lines in the previous plain-text format. Emit one JSON-encoded string per line instead so any byte sequence round-trips cleanly. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
GET /admin/filesthat streams filenames fromIMAGES_DIRone per line (text/plain), usingos.scandirso memory usage is flat regardless of store size.API_KEYviacheck_auth.?prefix=filtering and?limit=for sampling./{filename:path}catch-all so it is not swallowed as a filename lookup.Usage:
Test plan
curlwith valid key returns filenames, one per linecurlwithout / with wrong key returns 403?prefix=abcfilters results?limit=10caps results🤖 Generated with Claude Code