From c4972f7dc90b8edf27befbe8869865bfa1c607c3 Mon Sep 17 00:00:00 2001 From: SergeantPanda Date: Tue, 14 Apr 2026 13:34:17 -0500 Subject: [PATCH] fix: clear previous failure entries after successful logo fetch in LogoViewSet and VODLogoViewSet --- apps/channels/api_views.py | 6 +++--- apps/vod/api_views.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/channels/api_views.py b/apps/channels/api_views.py index 15534202..10d855db 100644 --- a/apps/channels/api_views.py +++ b/apps/channels/api_views.py @@ -2085,9 +2085,6 @@ class LogoViewSet(viewsets.ModelViewSet): headers={'User-Agent': user_agent} ) if remote_response.status_code == 200: - # Success — clear any previous failure entry - _logo_fetch_failures.pop(logo_url, None) - # Eagerly read the full image with a total time + size cap # so the greenlet is released quickly. chunks = [] @@ -2106,6 +2103,9 @@ class LogoViewSet(viewsets.ModelViewSet): chunks.append(chunk) body = b"".join(chunks) + # Full read succeeded, clear any previous failure entry + _logo_fetch_failures.pop(logo_url, None) + # Try to get content type from response headers first content_type = remote_response.headers.get("Content-Type") diff --git a/apps/vod/api_views.py b/apps/vod/api_views.py index f7bdf83c..67813251 100644 --- a/apps/vod/api_views.py +++ b/apps/vod/api_views.py @@ -856,9 +856,6 @@ class VODLogoViewSet(viewsets.ModelViewSet): _vod_logo_fetch_failures[logo.url] = now + _VOD_LOGO_FAIL_TTL return HttpResponse(status=404) - # Success — clear any previous failure entry - _vod_logo_fetch_failures.pop(logo.url, None) - # Eagerly read the full image with a total time + size cap # so the greenlet is released quickly. chunks = [] @@ -877,6 +874,9 @@ class VODLogoViewSet(viewsets.ModelViewSet): chunks.append(chunk) body = b"".join(chunks) + # Full read succeeded, clear any previous failure entry + _vod_logo_fetch_failures.pop(logo.url, None) + content_type = remote_response.headers.get('Content-Type', 'image/png') response = HttpResponse(body, content_type=content_type)