From 2d76363da5bdca8afe08c8d168832b58b2ab6701 Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Fri, 13 Jan 2023 06:22:47 -0700 Subject: [PATCH] Catch FileNotFoundError when getting file system stats (#5056) --- frigate/http.py | 4 ++++ frigate/stats.py | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/frigate/http.py b/frigate/http.py index 9b21053c5..1f4fb4e75 100644 --- a/frigate/http.py +++ b/frigate/http.py @@ -884,6 +884,10 @@ def get_recordings_storage_usage(): current_app.stats_tracking, current_app.hwaccel_errors, )["service"]["storage"][RECORD_DIR] + + if not recording_stats: + return jsonify({}) + total_mb = recording_stats["total"] camera_usages: dict[ diff --git a/frigate/stats.py b/frigate/stats.py index 97eba0bb9..86ac3780b 100644 --- a/frigate/stats.py +++ b/frigate/stats.py @@ -241,7 +241,11 @@ def stats_snapshot( } for path in [RECORD_DIR, CLIPS_DIR, CACHE_DIR, "/dev/shm"]: - storage_stats = shutil.disk_usage(path) + try: + storage_stats = shutil.disk_usage(path) + except FileNotFoundError: + stats["service"]["storage"][path] = {} + stats["service"]["storage"][path] = { "total": round(storage_stats.total / 1000000, 1), "used": round(storage_stats.used / 1000000, 1),