Delete review thumbnails

This commit is contained in:
Nicolas Mowen 2025-05-12 07:54:37 -06:00
parent 170688cc4c
commit a5c72db855

View File

@ -69,7 +69,7 @@ class RecordingCleanup(threading.Thread):
now - datetime.timedelta(days=config.record.detections.retain.days)
).timestamp()
expired_reviews: ReviewSegment = (
ReviewSegment.select(ReviewSegment.id)
ReviewSegment.select(ReviewSegment.id, ReviewSegment.thumb_path)
.where(ReviewSegment.camera == config.name)
.where(
(
@ -84,6 +84,10 @@ class RecordingCleanup(threading.Thread):
.namedtuples()
)
thumbs_to_delete = list(map(lambda x: x[1], expired_reviews))
for thumb_path in thumbs_to_delete:
Path(thumb_path).unlink(missing_ok=True)
max_deletes = 100000
deleted_reviews_list = list(map(lambda x: x[0], expired_reviews))
for i in range(0, len(deleted_reviews_list), max_deletes):