mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-11-27 15:57:07 +03:00
Event cleanup fixes (#25072)
* keep event cleanup running and fix storage usage keys - Event cleanup ran with no exception handling inside its loop, so one error (a camera added or removed while it iterated the shared cameras dict, a DB error, a thumbnail unlink failure) ended event and snapshot retention until restart. Each cycle is now guarded, camera iterations use a snapshot, and thumbnail unlink errors are caught - Camera keys were captured once at startup, so a camera added at runtime also matched the removed-camera branch and its events could expire early under the global retention. The keys are refreshed each cycle and the removed-camera label cache resets when they change - Clip expiry had no has_clip filter and redid every past expiration each cycle. The queries now skip events already expired, and the dead clip unlink block is removed - Storage usage was keyed by friendly name, so cameras sharing one merged into a single row. It is keyed by camera id and the storage graph resolves the display name * docstring
This commit is contained in:
@@ -440,6 +440,36 @@ class TestHttp(unittest.TestCase):
|
||||
assert usages["front_door"]["usage"] == 0
|
||||
assert usages["front_door"]["streams"] == {}
|
||||
|
||||
def test_camera_usages_keyed_by_camera_id(self):
|
||||
"""Cameras sharing a friendly name keep separate usage entries."""
|
||||
self.double_cam_config["cameras"]["front_door"]["friendly_name"] = "Door"
|
||||
self.double_cam_config["cameras"]["back_door"]["friendly_name"] = "Door"
|
||||
config = FrigateConfig(**self.double_cam_config)
|
||||
storage = StorageMaintainer(config, MagicMock())
|
||||
|
||||
time_keep = datetime.datetime.now().timestamp()
|
||||
_insert_mock_recording(
|
||||
"1234567.frontdoor",
|
||||
os.path.join(self.test_dir, "front.tmp"),
|
||||
time_keep,
|
||||
time_keep + 10,
|
||||
seg_size=20,
|
||||
)
|
||||
_insert_mock_recording(
|
||||
"1234568.backdoor",
|
||||
os.path.join(self.test_dir, "back.tmp"),
|
||||
time_keep,
|
||||
time_keep + 10,
|
||||
camera="back_door",
|
||||
seg_size=5,
|
||||
)
|
||||
|
||||
storage.calculate_camera_bandwidth()
|
||||
usages = storage.calculate_camera_usages()
|
||||
|
||||
assert usages["front_door"]["usage"] == 20
|
||||
assert usages["back_door"]["usage"] == 5
|
||||
|
||||
def test_storage_cleanup(self):
|
||||
"""Ensure that all recordings are cleaned up when necessary."""
|
||||
config = FrigateConfig(**self.minimal_config)
|
||||
|
||||
Reference in New Issue
Block a user