mirror of
https://github.com/ZoneMinder/zoneminder.git
synced 2026-05-31 09:55:51 -04:00
Unlike Event_Summaries, Storage.DiskSpace has no trigger-based incremental maintenance — Event::delete and the event-finalize paths do their own +/- adjustments in application code. The previous absolute snapshot+overwrite could undo a concurrent Event::delete adjustment that committed between our Events SUM SELECT and our Storage UPDATE, making accounting transiently wrong under normal load until the next zmaudit pass. Read the current Storage.DiskSpace alongside the aggregate, skip rows that are already correct, and UPDATE with a null-safe equality guard (MariaDB <=>) so a concurrent writer's newer value blocks the overwrite. Track CAS-deferred rows separately from failures and surface both counts in the audit log.