mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-09-27 13:28:58 +03:00
Fix 500 when an event thumbnail file is empty (#24110)
* fix 500 when an event thumbnail file is empty * fix test
This commit is contained in:
committed by
Nicolas Mowen
parent
0aa086eefd
commit
96013a0487
@@ -1060,7 +1060,7 @@ async def event_thumbnail(
|
||||
except DoesNotExist:
|
||||
thumbnail_bytes = None
|
||||
|
||||
if thumbnail_bytes is None:
|
||||
if not thumbnail_bytes:
|
||||
# see if the object is currently being tracked
|
||||
try:
|
||||
camera_states = request.app.detected_frames_processor.get_camera_states()
|
||||
@@ -1076,7 +1076,7 @@ async def event_thumbnail(
|
||||
status_code=404,
|
||||
)
|
||||
|
||||
if thumbnail_bytes is None:
|
||||
if not thumbnail_bytes:
|
||||
return JSONResponse(
|
||||
content={"success": False, "message": "Event not found"},
|
||||
status_code=404,
|
||||
@@ -1085,6 +1085,13 @@ async def event_thumbnail(
|
||||
img_as_np = np.frombuffer(thumbnail_bytes, dtype=np.uint8)
|
||||
img = cv2.imdecode(img_as_np, flags=1)
|
||||
|
||||
if img is None:
|
||||
# thumbnail on disk is truncated or corrupt
|
||||
return JSONResponse(
|
||||
content={"success": False, "message": "Event not found"},
|
||||
status_code=404,
|
||||
)
|
||||
|
||||
# android notifications prefer a 2:1 ratio
|
||||
if format == "android":
|
||||
img = cv2.copyMakeBorder(
|
||||
|
||||
Reference in New Issue
Block a user