From c6918d34770d75d771857bd66784cb4ba8ac0c0b Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Sat, 6 Dec 2025 07:53:09 -0700 Subject: [PATCH] Move files into try for classification rollover --- .../real_time/custom_classification.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/frigate/data_processing/real_time/custom_classification.py b/frigate/data_processing/real_time/custom_classification.py index c8f31db76..25ec3bb86 100644 --- a/frigate/data_processing/real_time/custom_classification.py +++ b/frigate/data_processing/real_time/custom_classification.py @@ -639,14 +639,14 @@ def write_classification_attempt( os.makedirs(folder, exist_ok=True) cv2.imwrite(file, frame) - files = sorted( - filter(lambda f: (f.endswith(".webp")), os.listdir(folder)), - key=lambda f: os.path.getctime(os.path.join(folder, f)), - reverse=True, - ) - # delete oldest face image if maximum is reached try: + files = sorted( + filter(lambda f: (f.endswith(".webp")), os.listdir(folder)), + key=lambda f: os.path.getctime(os.path.join(folder, f)), + reverse=True, + ) + if len(files) > max_files: os.unlink(os.path.join(folder, files[-1])) except FileNotFoundError: