Catch FileNotFoundError when getting file system stats (#5056)

This commit is contained in:
Nicolas Mowen 2023-01-13 06:22:47 -07:00 committed by GitHub
parent 54bfa4679c
commit 2d76363da5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

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

View File

@ -241,7 +241,11 @@ def stats_snapshot(
}
for path in [RECORD_DIR, CLIPS_DIR, CACHE_DIR, "/dev/shm"]:
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),