diff --git a/frigate/mypy.ini b/frigate/mypy.ini index f7b7aee22..0ae5de485 100644 --- a/frigate/mypy.ini +++ b/frigate/mypy.ini @@ -71,6 +71,9 @@ ignore_errors = false [mypy-frigate.stats] ignore_errors = false +[mypy-frigate.storage] +ignore_errors = false + [mypy-frigate.track.*] ignore_errors = false diff --git a/frigate/storage.py b/frigate/storage.py index dad3c6e9c..8cc199a1b 100644 --- a/frigate/storage.py +++ b/frigate/storage.py @@ -3,6 +3,7 @@ import logging import shutil import threading +from multiprocessing.synchronize import Event as MpEvent from pathlib import Path from peewee import SQL, fn @@ -23,7 +24,7 @@ MAX_CALCULATED_BANDWIDTH = 10000 # 10Gb/hr class StorageMaintainer(threading.Thread): """Maintain frigates recording storage.""" - def __init__(self, config: FrigateConfig, stop_event) -> None: + def __init__(self, config: FrigateConfig, stop_event: MpEvent) -> None: super().__init__(name="storage_maintainer") self.config = config self.stop_event = stop_event @@ -114,7 +115,7 @@ class StorageMaintainer(threading.Thread): logger.debug( f"Storage cleanup check: {hourly_bandwidth} hourly with remaining storage: {remaining_storage}." ) - return remaining_storage < hourly_bandwidth + return remaining_storage < float(hourly_bandwidth) def reduce_storage_consumption(self) -> None: """Remove oldest hour of recordings.""" @@ -124,7 +125,7 @@ class StorageMaintainer(threading.Thread): [b["bandwidth"] for b in self.camera_storage_stats.values()] ) - recordings: Recordings = ( + recordings = ( Recordings.select( Recordings.id, Recordings.camera, @@ -138,7 +139,7 @@ class StorageMaintainer(threading.Thread): .iterator() ) - retained_events: Event = ( + retained_events = ( Event.select( Event.start_time, Event.end_time, @@ -278,7 +279,7 @@ class StorageMaintainer(threading.Thread): Recordings.id << deleted_recordings_list[i : i + max_deletes] ).execute() - def run(self): + def run(self) -> None: """Check every 5 minutes if storage needs to be cleaned up.""" if self.config.safe_mode: logger.info("Safe mode enabled, skipping storage maintenance")