Skip to content

fix: harden transcode cache integrity and cleanup - #499

Closed
JHNY5 wants to merge 1 commit into
blackcandy-org:masterfrom
JHNY5:fix/transcode-cache-integrity
Closed

fix: harden transcode cache integrity and cleanup#499
JHNY5 wants to merge 1 commit into
blackcandy-org:masterfrom
JHNY5:fix/transcode-cache-integrity

Conversation

@JHNY5

@JHNY5 JHNY5 commented Aug 13, 2026

Copy link
Copy Markdown

Summary

Prevents serving corrupt or stale transcoded audio from cache.

Problem

The transcode cache integrity check (valid_cache?) only compares tag duration (±2s) via WahWah. This accepts an empty or partially-written cache file (serving a 0-byte audio response) and never evicts stale entries, so a changed bitrate or replaced media can leave permanently-wrong content cached for a song id.

Changes

  • app/controllers/transcoded_stream_controller.rb: valid_cache? now rejects missing or zero-length cache files before trusting the duration comparison
  • app/models/stream.rb: new Stream#clean_transcode_cache! evicts stale cache entries for a song (bitrate/source changes)
  • test/controllers/transcoded_stream_controller_test.rb: regression test for the empty-cache case

Verification

  • Live-tested against a booted instance with the patch: an empty cache file is regenerated, stale caches are evicted, normal streaming unchanged
  • Existing transcoded-stream tests remain valid (covered by CI)

This is the master-targeted component; a separate PR targets the v3.2.0 release branch where the API-level fixes live.

@JHNY5
JHNY5 marked this pull request as ready for review August 14, 2026 00:15
@aidewoode

Copy link
Copy Markdown
Member

WahWah already handle these check. so no need to do it again.

@aidewoode aidewoode closed this Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants