Commit Graph
8 Commits
Author SHA1 Message Date
2c32cc6307 fix: keep recording when the Events insert fails, and let zmrecover give the event a normal id refs #7999 (#8409)
* fix: record an event under a time-based id when its insert keeps failing refs #7999

* fix: an event whose insert fails while zmc shuts down records under a fallback id too refs #7987

Event::Event stopped retrying the Events insert as soon as zm_terminate was
set, leaving the event with id 0, so its frames and video were written under
event 0. It now takes the same time-based fallback id it uses after three
failed attempts, so the recording is kept and zmrecover.pl can add it.
Monitor::openEvent never sees an id of 0 any more.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat: zmrecover gives an event recorded under a fallback id a normal id, and zmaudit keeps it refs #7999

When zmc cannot insert an event's row it records the event under a time-based
id far above the auto increment range. Recovering it as-is would leave that id
in the Events table and push auto increment past it.

ZoneMinder::Event::save_with_new_id() inserts the row without an Id, so it gets
the next auto increment id, then moves the event to match: the Medium or
Shallow directory, the Deep .<id> link or Shallow .<id> file, the
<id>-video.* file, the eid and file name in index.m3u8, DefaultVideo, the
recovered name, and any Frames, Stats, Event_Data, Events_Tags,
Snapshots_Events and Events_* summary rows zmc queued under the old id. If the
directory cannot be moved it removes the new row and keeps the old id, so a
later run can try again. zmrecover.pl saves every recovered event through it
when the id is in the fallback range.

zmaudit deleted the files of any event with no row once it was older than
ZM_AUDIT_MIN_AGE, which would throw away exactly the video the fallback id
exists to keep. It now warns and leaves those events for zmrecover.pl, and its
orphaned Frames, Stats and Event_Data cleanups stop below the fallback range.

The zmaudit and zmrecover tests that replace ZoneMinder::Event with a stub get
the two new names.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Jash <jashambaliya1@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 08:48:23 -05:00
Jash Ambaliya c5370def67 fix: zmc escapes the expanded EventPrefix in the query that closes an event refs #7574 (#7575) 2026-11-27 08:47:34 -05:00
Isaac ConnorandClaude Opus 5.5 3a3ac45593 Merge master into event-section-rollover-counts
Resolve the conflicts in src/zm_event.h and tests/zm_event_score.cpp by
keeping both sides: master's ClampSectionLength, EventNamePrefixLength and
BuildNotes tests next to this branch's EventCountsFrameStats and
EventKeepsDraining. Brings in the NEON blend fix the macOS job needs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 12:17:56 -05:00
Jash 9851ddfc7e fix: do not count rollover overlap frames twice in event stats refs #5987 2026-11-15 14:38:08 +05:30
Jash 56982420b4 fix: truncate the expanded EventPrefix so the closing UPDATE fits Events.Name refs #5948 2026-11-15 00:41:23 +05:30
Jash 94bdd0a106 fix: store the Signal Lost/Reacquired event note and separate note groups refs #5948 2026-11-15 00:41:23 +05:30
Jash dc4f3211b0 fix: clamp SectionLength to 1 second so a value of 0 no longer crashes zmc with SIGFPE refs #5948 2026-11-15 00:41:23 +05:30
Nic BoetandClaude Opus 5.5 cd441866d1 fix: store MaxScore 0 when an event closes before its first frame
Event::max_score starts at -1 and only AddPacket_ raises it. An event
closed before the event thread wrote a frame (a signal flap, a reload or
an alarm cancelled right after the event opened) sent MaxScore = -1 in
its closing UPDATE. Events.MaxScore is smallint unsigned, so in strict
SQL mode MariaDB refused the whole statement ("Out of range value for
column 'MaxScore'"): EndDateTime, Frames and DefaultVideo stayed unset
and the event looked as if it was still recording, while the video had
already been renamed to its final name.

Clamp the value to 0 in the closing UPDATE. The -1 start stays, so the
first frame still becomes the max-score frame.

fixes #5233

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-12 11:13:47 -05:00