Add explanatory warning and properly format cache_path warning

This commit is contained in:
Deviant 2022-07-18 23:53:19 +01:00
parent 73f2c827c6
commit 5495896154

View File

@ -99,12 +99,15 @@ class RecordingMaintainer(threading.Thread):
# delete all cached files past the most recent 5
keep_count = 5
for camera in grouped_recordings.keys():
if len(grouped_recordings[camera]) > keep_count:
segment_count = len(grouped_recordings[camera])
if segment_count > keep_count:
logger.warning(f"Too many recording segments in cache for {camera}. Keeping the {keep_count} most recent segments out of {segment_count}, discarding the rest...")
to_remove = grouped_recordings[camera][:-keep_count]
for f in to_remove:
logger.warning(f"Discarding a recording segment: {f}")
Path(f["cache_path"]).unlink(missing_ok=True)
self.end_time_cache.pop(f["cache_path"], None)
cache_path = f["cache_path"]
logger.warning(f"Discarding a recording segment: {cache_path}")
Path(cache_path).unlink(missing_ok=True)
self.end_time_cache.pop(cache_path, None)
grouped_recordings[camera] = grouped_recordings[camera][-keep_count:]
for camera, recordings in grouped_recordings.items():