feat(score): score PDF storage + IPC (clearfolio viewer contract, PR 1/3)#581
Open
seonghobae wants to merge 1 commit into
Open
feat(score): score PDF storage + IPC (clearfolio viewer contract, PR 1/3)#581seonghobae wants to merge 1 commit into
seonghobae wants to merge 1 commit into
Conversation
…1/3)
Add three Tauri commands backing the upcoming score viewer:
- attach_score_pdf(project_id, song_id): OS file dialog (.pdf only),
validates %PDF- magic bytes and a 25MB size cap, copies the file
into the app-owned <app_local_data_dir>/<project_id>/scores/<uuid>.pdf
and returns {scoreId, fileName, fileSizeBytes}.
- read_score_pdf(project_id, score_id): strict lowercase-UUID allowlist,
path rebuilt locally, canonicalize + prefix guard against traversal,
returns file bytes.
- remove_score_pdf(project_id, score_id): same guards, idempotent delete.
Project ids are validated against the exact shape minted by
next_project_id (project-<nanos>-<counter>) before any path join.
Pure helpers are separated from the command wrappers and covered by
unit tests (uuid guard, traversal/symlink rejection, magic-byte and
size checks).
Drive-by fix: import_youtube_url, save_project, and load_project were
registered in the invoke handler but missing from the build.rs app
manifest and capabilities/main.json, so their permissions were never
generated or granted. Added them alongside the new score commands.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RjGVapDZ3k7V7zKYk16P4C
This was referenced Jul 7, 2026
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.
What
PR 1 of 3 for the 악보 (Score PDF) feature: Rust storage + IPC only. The React viewer ships in a later PR.
New Tauri commands in
apps/desktop/src-tauri/src/main.rs:attach_score_pdf(project_id, song_id)— opens an OS file dialog filtered to.pdf, validates the selection (%PDF-magic bytes, ≤ 25MB, real non-symlinked file), copies it into the app-owned<app_local_data_dir>/<project_id>/scores/<uuid>.pdf, and returns{scoreId, fileName, fileSizeBytes}.read_score_pdf(project_id, score_id)— validates both ids against strict allowlist shapes, rebuilds the path locally, canonicalizes and enforces the scores-root prefix, returns the file bytes.remove_score_pdf(project_id, score_id)— same guards; idempotent delete returningbool.All three are registered in the invoke handler, the
build.rsapp manifest, andcapabilities/main.json.Why
Adopts the clearfolio viewer IPC contract (
scoreId/fileName/fileSizeBytespayload plus attach/read/remove verbs) so the later viewer PR can drop in against a stable backend surface.License blocker note: clearfolio's contract shape is adopted as a design reference only — no clearfolio code is vendored or copied into this repository, keeping BandScope clear of clearfolio's license terms. Everything here is an independent implementation following BandScope's existing command patterns (
normalize_local_audio_source,youtube_source_from_metadata).Drive-by fix
import_youtube_url,save_project, andload_projectwere registered in the invoke handler but missing from thebuild.rsapp manifest andcapabilities/main.json, so their permissions were never autogenerated or granted to the main window. They are now listed in both, and the autogenerated permission TOMLs are committed.Security Notes
User Input Boundary), three new IPC commands (IPC Boundary), app-owned score storage (Storage Boundary).project_id/score_id, symlink escapes out of the app data dir, mislabeled or oversized non-PDF files attached as scores, JS-supplied arbitrary paths.%PDF-) + 25MB size + extension + non-symlink + regular-file validation before the copy.project_idmust match the exact shape minted bynext_project_id(project-<digits>-<digits>);score_idmust be an exact lowercase hyphenated UUID. Both are allowlist checks with no separators or..possible.Tests
cargo fmt --check,cargo clippy -- -D warnings,cargo test(12 passed, incl. 4 new score tests)npm run lint,npm run typecheck,npm run build,npm run check:rust— greenapps/desktop/src/App.test.tsxreproduces identically on a cleandevelopcheckout and is unrelated (no TS/JS source touched here).🤖 Generated with Claude Code