From 0d4118f590da54b2535151a64257674ad0ba1a2a Mon Sep 17 00:00:00 2001 From: Nick Mowen Date: Tue, 27 Sep 2022 09:59:49 -0600 Subject: [PATCH] Catch case where camera has 0 nonzero segment durations --- frigate/storage.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/frigate/storage.py b/frigate/storage.py index aa8724553..bd328e91f 100644 --- a/frigate/storage.py +++ b/frigate/storage.py @@ -45,14 +45,18 @@ class StorageMaintainer(threading.Thread): } # calculate MB/hr - bandwidth = round( - Recordings.select(fn.AVG(bandwidth_equation)) - .where(Recordings.camera == camera, Recordings.segment_size != 0) - .limit(100) - .scalar() - * 3600, - 2, - ) + try: + bandwidth = round( + Recordings.select(fn.AVG(bandwidth_equation)) + .where(Recordings.camera == camera, Recordings.segment_size != 0) + .limit(100) + .scalar() + * 3600, + 2, + ) + except TypeError: + bandwidth = 0 + self.camera_storage_stats[camera]["bandwidth"] = bandwidth logger.debug(f"{camera} has a bandwidth of {bandwidth} MB/hr.")