fix(podcasts): guard public stream against missing audio

This commit is contained in:
CREDO23 2026-06-16 19:12:09 +02:00
parent 0c2808640a
commit 1d70af4684

View file

@ -103,8 +103,14 @@ async def stream_public_podcast(
if storage_key:
from app.file_storage.factory import get_storage_backend
backend = get_storage_backend()
# Verify first so a missing object is a 404, not a mid-stream crash.
if not await backend.exists(storage_key):
raise HTTPException(
status_code=404, detail="Podcast audio is no longer available"
)
return StreamingResponse(
get_storage_backend().open_stream(storage_key),
backend.open_stream(storage_key),
media_type="audio/mpeg",
headers={"Accept-Ranges": "bytes"},
)