fix: clear previous failure entries after successful logo fetch in LogoViewSet and VODLogoViewSet

This commit is contained in:
SergeantPanda 2026-04-14 13:34:17 -05:00
parent 978714a74d
commit c4972f7dc9
2 changed files with 6 additions and 6 deletions

View file

@ -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")

View file

@ -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)