feedBack/tests
Byron Gamatos 21997f4b5c
Fix slow library cover loading: serve sloppak art without unpacking + revalidated caching (#534)
* sloppak: read cover without unpacking + serialize/cap zip unpacks

Album art for a zip-form sloppak was served by resolve_source_dir(), which
unpacks the ENTIRE archive (stems included, ~30 MB) to disk just to read
cover.jpg. On the library grid that meant a full extraction per card on scroll.

- read_cover_bytes(): opens only the cover member from the zip (or reads the
  file for dir-form), with zip-slip guarding. ~4 ms vs a full unpack.
- resolve_source_dir(): per-file lock + bounded global semaphore so concurrent
  callers don't rmtree + re-extract the same dest at once (a race), and a burst
  can't saturate disk/CPU. 8 concurrent calls now dedupe to 1 unpack.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* server: serve sloppak art via read_cover_bytes + cache album-art responses

- get_song_art() sloppak branch now reads the cover directly (no full unpack),
  off-thread via asyncio.to_thread.
- All art responses carry Cache-Control: public, max-age=86400. URLs are already
  cache-busted with ?v=<mtime>, so the browser stops re-fetching every cover on
  scroll-back; day bound self-heals any URL missing ?v.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* v3 library: lazy-load + async-decode card cover images

The grid (24 cards/page) and artist-row thumbnails emitted plain <img> with no
loading hint, so a whole page of covers fetched + decoded at once on each
scroll batch. Add loading="lazy" decoding="async" to defer off-screen fetches
and keep image decode off the main thread.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* address Codex review: zip cover normalization + correct art revalidation

Findings from the preflight Codex passes:

- sloppak.read_cover_bytes (zip form) read the raw manifest cover string via
  zf.read(), so a non-canonical name like './cover.jpg' or 'art/../cover.jpg'
  404'd. Normalize via safe_join → relative member; reject escape and the
  degenerate root-collapse case ('.', 'subdir/..') like _unpack_zip does.

- Album-art caching is correctness-first: Cache-Control: no-cache plus a strong
  validator, with real conditional handling (Starlette FileResponse emits an
  ETag but doesn't evaluate If-None-Match). All three art paths route through
  _art_conditional/_file_art_response → bodyless 304 on a matching validator.
  A long immutable max-age was rejected because the frontend ?v=<mtime> buster
  is only second-resolution and would pin a same-second rewrite.

- The sloppak cover is validated by CONTENT (sha1 of the bytes), not a stat:
  a dir-form sloppak edited in place changes the cover file's mtime but not the
  directory's, so a dir-stat ETag could emit a stale 304. Content hashing is
  correct for both dir- and zip-form. get_song_art gained an optional request
  (internal get_art caller passes none — safe).

Adds tests/test_sloppak_cover_art.py pinning read_cover_bytes (canonical,
non-canonical, degenerate/escape, dir/zip, webp) and the endpoint's 304 contract
incl. the dir-form in-place-edit no-stale-304 regression.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-20 00:22:43 +02:00
..
browser Purge external-format terminology from code, tests and docs 2026-06-16 19:36:53 +01:00
fixtures Remove unused binary test fixture; correct stale scan comments 2026-06-16 18:49:40 +01:00
js feat(onboarding): input-device setup step + core-owned midi-input domain (#526) 2026-06-19 16:31:16 +02:00
plugins Clean release snapshot 2026-06-16 18:47:13 +02:00
__init__.py Clean release snapshot 2026-06-16 18:47:13 +02:00
conftest.py Clean release snapshot 2026-06-16 18:47:13 +02:00
test_audio_bundled.py Clean release snapshot 2026-06-16 18:47:13 +02:00
test_audio_effect_mappings.py Purge external-format terminology from code, tests and docs 2026-06-16 19:36:53 +01:00
test_audio_local_path.py Clean release snapshot 2026-06-16 18:47:13 +02:00
test_audio.py Clean release snapshot 2026-06-16 18:47:13 +02:00
test_builtin_diagnostic_seed.py Clean release snapshot 2026-06-16 18:47:13 +02:00
test_correlation_id.py Clean release snapshot 2026-06-16 18:47:13 +02:00
test_demo_mode.py Clean release snapshot 2026-06-16 18:47:13 +02:00
test_diagnostics_bundle.py Purge external-format terminology from code, tests and docs 2026-06-16 19:36:53 +01:00
test_diagnostics_hardware.py Clean release snapshot 2026-06-16 18:47:13 +02:00
test_diagnostics_redact.py Purge external-format terminology from code, tests and docs 2026-06-16 19:36:53 +01:00
test_drums_lib.py Purge external-format terminology from code, tests and docs 2026-06-16 19:36:53 +01:00
test_gp2midi.py Clean release snapshot 2026-06-16 18:47:13 +02:00
test_gp2notation.py Clean release snapshot 2026-06-16 18:47:13 +02:00
test_gp2rs_drums.py Clean release snapshot 2026-06-16 18:47:13 +02:00
test_gp2rs_gpx.py Clean release snapshot 2026-06-16 18:47:13 +02:00
test_gp2rs.py Clean release snapshot 2026-06-16 18:47:13 +02:00
test_gp_audio_sync.py Clean release snapshot 2026-06-16 18:47:13 +02:00
test_highway_3d_routes.py Clean release snapshot 2026-06-16 18:47:13 +02:00
test_highway_ws_notation.py Clean release snapshot 2026-06-16 18:47:13 +02:00
test_library_filters.py Improve wording in terminology cleanup 2026-06-16 19:43:45 +01:00
test_library_providers.py Purge external-format terminology from code, tests and docs 2026-06-16 19:36:53 +01:00
test_lift_keys_notation.py Clean release snapshot 2026-06-16 18:47:13 +02:00
test_logging_setup.py Clean release snapshot 2026-06-16 18:47:13 +02:00
test_loose_traversal.py Purge external-format terminology from code, tests and docs 2026-06-16 19:36:53 +01:00
test_loosefolder.py Purge external-format terminology from code, tests and docs 2026-06-16 19:36:53 +01:00
test_lyrics_transcribe.py Purge external-format terminology from code, tests and docs 2026-06-16 19:36:53 +01:00
test_midi_import_drums.py Clean release snapshot 2026-06-16 18:47:13 +02:00
test_midi_import.py Clean release snapshot 2026-06-16 18:47:13 +02:00
test_minigames_routes.py Clean release snapshot 2026-06-16 18:47:13 +02:00
test_notation_lib.py Clean release snapshot 2026-06-16 18:47:13 +02:00
test_notation_lift.py Clean release snapshot 2026-06-16 18:47:13 +02:00
test_notation_to_notes.py Clean release snapshot 2026-06-16 18:47:13 +02:00
test_parse_arrangement.py Purge external-format terminology from code, tests and docs 2026-06-16 19:36:53 +01:00
test_playlists_api.py Purge external-format terminology from code, tests and docs 2026-06-16 19:36:53 +01:00
test_plugin_manifest_contract.py Clean release snapshot 2026-06-16 18:47:13 +02:00
test_plugin_runtime_idempotence.py Clean release snapshot 2026-06-16 18:47:13 +02:00
test_plugins.py Clean release snapshot 2026-06-16 18:47:13 +02:00
test_profile_api.py Clean release snapshot 2026-06-16 18:47:13 +02:00
test_profile_domains.py Clean release snapshot 2026-06-16 18:47:13 +02:00
test_progression_api.py Purge external-format terminology from code, tests and docs 2026-06-16 19:36:53 +01:00
test_progression.py Purge external-format terminology from code, tests and docs 2026-06-16 19:36:53 +01:00
test_safepath.py Clean release snapshot 2026-06-16 18:47:13 +02:00
test_settings_api.py Make the library loader sloppak/loose-only 2026-06-16 19:09:53 +01:00
test_settings_export.py Make the library loader sloppak/loose-only 2026-06-16 19:09:53 +01:00
test_settings_instrument.py Clean release snapshot 2026-06-16 18:47:13 +02:00
test_sloppak_cent_offset.py Clean release snapshot 2026-06-16 18:47:13 +02:00
test_sloppak_cover_art.py Fix slow library cover loading: serve sloppak art without unpacking + revalidated caching (#534) 2026-06-20 00:22:43 +02:00
test_sloppak_drumtab_load.py Clean release snapshot 2026-06-16 18:47:13 +02:00
test_sloppak_file_traversal.py Clean release snapshot 2026-06-16 18:47:13 +02:00
test_sloppak_notation_load.py Clean release snapshot 2026-06-16 18:47:13 +02:00
test_sloppak_song_timeline_load.py Clean release snapshot 2026-06-16 18:47:13 +02:00
test_song_score.py Clean release snapshot 2026-06-16 18:47:13 +02:00
test_song_stats_api.py Purge external-format terminology from code, tests and docs 2026-06-16 19:36:53 +01:00
test_song.py Improve wording in terminology cleanup 2026-06-16 19:43:45 +01:00
test_songmeta.py Clean release snapshot 2026-06-16 18:47:13 +02:00
test_startup_status.py Clean release snapshot 2026-06-16 18:47:13 +02:00
test_tailwind_rebuild.py Clean release snapshot 2026-06-16 18:47:13 +02:00
test_tones.py Clean release snapshot 2026-06-16 18:47:13 +02:00
test_tunings.py Clean release snapshot 2026-06-16 18:47:13 +02:00
test_version_endpoint.py Repoint dead slopsmith URLs -> got-feedback 2026-06-17 11:02:04 +02:00
test_vocal_pitch.py Clean release snapshot 2026-06-16 18:47:13 +02:00
test_xp.py Clean release snapshot 2026-06-16 18:47:13 +02:00