Fix manual event getting caught by global motion config (#22887)

This commit is contained in:
Nicolas Mowen 2026-04-15 08:32:26 -06:00 committed by GitHub
parent 82e14d71fb
commit 2ffe47511a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -372,6 +372,7 @@ class RecordingMaintainer(threading.Thread):
) )
record_config = self.config.cameras[camera].record record_config = self.config.cameras[camera].record
segment_info: SegmentInfo | None = None
highest = None highest = None
if record_config.continuous.days > 0: if record_config.continuous.days > 0:
@ -401,8 +402,18 @@ class RecordingMaintainer(threading.Thread):
if highest == "continuous" if highest == "continuous"
else RetainModeEnum.motion else RetainModeEnum.motion
) )
segment_info = self.segment_stats(camera, start_time, end_time)
# Here we only check if we should move the segment based on non-object recording retention
# we will always want to check for overlapping review items below before dropping the segment
if not segment_info.should_discard_segment(record_mode):
return await self.move_segment( return await self.move_segment(
camera, start_time, end_time, duration, cache_path, record_mode camera,
start_time,
end_time,
duration,
cache_path,
segment_info,
) )
# we fell through the continuous / motion check, so we need to check the review items # we fell through the continuous / motion check, so we need to check the review items
@ -435,6 +446,11 @@ class RecordingMaintainer(threading.Thread):
if review.severity == "alert" if review.severity == "alert"
else record_config.detections.retain.mode else record_config.detections.retain.mode
) )
if segment_info is None:
segment_info = self.segment_stats(camera, start_time, end_time)
if not segment_info.should_discard_segment(record_mode):
# move from cache to recordings immediately # move from cache to recordings immediately
return await self.move_segment( return await self.move_segment(
camera, camera,
@ -442,8 +458,12 @@ class RecordingMaintainer(threading.Thread):
end_time, end_time,
duration, duration,
cache_path, cache_path,
record_mode, segment_info,
) )
else:
self.drop_segment(cache_path)
return None
# if it doesn't overlap with an review item, go ahead and drop the segment # if it doesn't overlap with an review item, go ahead and drop the segment
# if it ends more than the configured pre_capture for the camera # if it ends more than the configured pre_capture for the camera
# BUT only if continuous/motion is NOT enabled (otherwise wait for processing) # BUT only if continuous/motion is NOT enabled (otherwise wait for processing)
@ -455,6 +475,7 @@ class RecordingMaintainer(threading.Thread):
retain_cutoff = datetime.datetime.fromtimestamp( retain_cutoff = datetime.datetime.fromtimestamp(
most_recently_processed_frame_time - record_config.event_pre_capture most_recently_processed_frame_time - record_config.event_pre_capture
).astimezone(datetime.timezone.utc) ).astimezone(datetime.timezone.utc)
if end_time < retain_cutoff: if end_time < retain_cutoff:
self.drop_segment(cache_path) self.drop_segment(cache_path)
@ -578,15 +599,8 @@ class RecordingMaintainer(threading.Thread):
end_time: datetime.datetime, end_time: datetime.datetime,
duration: float, duration: float,
cache_path: str, cache_path: str,
store_mode: RetainModeEnum, segment_info: SegmentInfo,
) -> Optional[dict[str, Any]]: ) -> Optional[dict[str, Any]]:
segment_info = self.segment_stats(camera, start_time, end_time)
# check if the segment shouldn't be stored
if segment_info.should_discard_segment(store_mode):
self.drop_segment(cache_path)
return None
# directory will be in utc due to start_time being in utc # directory will be in utc due to start_time being in utc
directory = os.path.join( directory = os.path.join(
RECORD_DIR, RECORD_DIR,