From f8c0f74ab89e00a23412664d65a20c4ee6aaae67 Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Fri, 28 Jul 2023 04:49:52 -0600 Subject: [PATCH] Batch delete recordings for removed cameras as well (#7302) --- frigate/record/cleanup.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/frigate/record/cleanup.py b/frigate/record/cleanup.py index 4600ce036..33fcbe398 100644 --- a/frigate/record/cleanup.py +++ b/frigate/record/cleanup.py @@ -59,7 +59,13 @@ class RecordingCleanup(threading.Thread): deleted_recordings.add(recording.id) logger.debug(f"Expiring {len(deleted_recordings)} recordings") - Recordings.delete().where(Recordings.id << deleted_recordings).execute() + # delete up to 100,000 at a time + max_deletes = 100000 + deleted_recordings_list = list(deleted_recordings) + for i in range(0, len(deleted_recordings_list), max_deletes): + Recordings.delete().where( + Recordings.id << deleted_recordings_list[i : i + max_deletes] + ).execute() logger.debug("End deleted cameras.") logger.debug("Start all cameras.")