mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-09 04:35:25 +03:00
Add better error handling
This commit is contained in:
parent
bcbea8da7d
commit
6eddba44ec
@ -663,6 +663,14 @@ def event_preview(id: str, max_cache_age=2592000):
|
|||||||
ffmpeg_cmd,
|
ffmpeg_cmd,
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if process.returncode != 0:
|
||||||
|
logger.error(process.stderr)
|
||||||
|
return make_response(
|
||||||
|
jsonify({"success": False, "message": "Unable to create preview gif"}),
|
||||||
|
500,
|
||||||
|
)
|
||||||
|
|
||||||
gif_bytes = process.stdout
|
gif_bytes = process.stdout
|
||||||
else:
|
else:
|
||||||
# need to generate from existing images
|
# need to generate from existing images
|
||||||
@ -723,6 +731,7 @@ def event_preview(id: str, max_cache_age=2592000):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if process.returncode != 0:
|
if process.returncode != 0:
|
||||||
|
logger.error(process.stderr)
|
||||||
return make_response(
|
return make_response(
|
||||||
jsonify({"success": False, "message": "Unable to create preview gif"}),
|
jsonify({"success": False, "message": "Unable to create preview gif"}),
|
||||||
500,
|
500,
|
||||||
@ -1031,9 +1040,9 @@ def event_snapshot(id):
|
|||||||
else:
|
else:
|
||||||
response.headers["Cache-Control"] = "no-store"
|
response.headers["Cache-Control"] = "no-store"
|
||||||
if download:
|
if download:
|
||||||
response.headers[
|
response.headers["Content-Disposition"] = (
|
||||||
"Content-Disposition"
|
f"attachment; filename=snapshot-{id}.jpg"
|
||||||
] = f"attachment; filename=snapshot-{id}.jpg"
|
)
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
@ -1220,9 +1229,9 @@ def event_clip(id):
|
|||||||
if download:
|
if download:
|
||||||
response.headers["Content-Disposition"] = "attachment; filename=%s" % file_name
|
response.headers["Content-Disposition"] = "attachment; filename=%s" % file_name
|
||||||
response.headers["Content-Length"] = os.path.getsize(clip_path)
|
response.headers["Content-Length"] = os.path.getsize(clip_path)
|
||||||
response.headers[
|
response.headers["X-Accel-Redirect"] = (
|
||||||
"X-Accel-Redirect"
|
f"/clips/{file_name}" # nginx: https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_ignore_headers
|
||||||
] = f"/clips/{file_name}" # nginx: https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_ignore_headers
|
)
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
|
||||||
@ -1927,9 +1936,9 @@ def get_recordings_storage_usage():
|
|||||||
|
|
||||||
total_mb = recording_stats["total"]
|
total_mb = recording_stats["total"]
|
||||||
|
|
||||||
camera_usages: dict[
|
camera_usages: dict[str, dict] = (
|
||||||
str, dict
|
current_app.storage_maintainer.calculate_camera_usages()
|
||||||
] = current_app.storage_maintainer.calculate_camera_usages()
|
)
|
||||||
|
|
||||||
for camera_name in camera_usages.keys():
|
for camera_name in camera_usages.keys():
|
||||||
if camera_usages.get(camera_name, {}).get("usage"):
|
if camera_usages.get(camera_name, {}).get("usage"):
|
||||||
@ -2117,9 +2126,9 @@ def recording_clip(camera_name, start_ts, end_ts):
|
|||||||
if download:
|
if download:
|
||||||
response.headers["Content-Disposition"] = "attachment; filename=%s" % file_name
|
response.headers["Content-Disposition"] = "attachment; filename=%s" % file_name
|
||||||
response.headers["Content-Length"] = os.path.getsize(path)
|
response.headers["Content-Length"] = os.path.getsize(path)
|
||||||
response.headers[
|
response.headers["X-Accel-Redirect"] = (
|
||||||
"X-Accel-Redirect"
|
f"/cache/{file_name}" # nginx: https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_ignore_headers
|
||||||
] = f"/cache/{file_name}" # nginx: https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_ignore_headers
|
)
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user