fix(recording): handle unexpected filenames in cache maintainer to prevent crash

This commit is contained in:
kirill kulakov 2026-01-15 21:20:22 -06:00
parent bf099c3edd
commit 63eaee3f57

View File

@ -112,7 +112,12 @@ class RecordingMaintainer(threading.Thread):
for cache in cache_files:
cache_path = os.path.join(CACHE_DIR, cache)
basename = os.path.splitext(cache)[0]
camera, date = basename.rsplit("@", maxsplit=1)
try:
camera, date = basename.rsplit("@", maxsplit=1)
except ValueError:
logger.warning(f"Skipping unexpected file in cache: {cache}")
continue
start_time = datetime.datetime.strptime(
date, CACHE_SEGMENT_FORMAT
).astimezone(datetime.timezone.utc)
@ -164,7 +169,11 @@ class RecordingMaintainer(threading.Thread):
cache_path = os.path.join(CACHE_DIR, cache)
basename = os.path.splitext(cache)[0]
camera, date = basename.rsplit("@", maxsplit=1)
try:
camera, date = basename.rsplit("@", maxsplit=1)
except ValueError:
logger.warning(f"Skipping unexpected file in cache: {cache}")
continue
# important that start_time is utc because recordings are stored and compared in utc
start_time = datetime.datetime.strptime(