From 8e584cf84498383170ec3e1e475f16c0b82e0697 Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Sat, 15 Jul 2023 07:38:21 -0600 Subject: [PATCH] Add option for enabling sync recordings (#7169) --- docs/docs/configuration/index.md | 2 ++ docs/docs/configuration/record.md | 15 +++++++++++++++ frigate/config.py | 3 +++ frigate/record/cleanup.py | 5 +++-- 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/docs/docs/configuration/index.md b/docs/docs/configuration/index.md index c4be86db0..d3573251a 100644 --- a/docs/docs/configuration/index.md +++ b/docs/docs/configuration/index.md @@ -341,6 +341,8 @@ record: # Optional: Number of minutes to wait between cleanup runs (default: shown below) # This can be used to reduce the frequency of deleting recording segments from disk if you want to minimize i/o expire_interval: 60 + # Optional: Sync recordings with disk on startup (default: shown below). + sync_on_startup: False # Optional: Retention settings for recording retain: # Optional: Number of days to retain recordings regardless of events (default: shown below) diff --git a/docs/docs/configuration/record.md b/docs/docs/configuration/record.md index 29a2fb36b..a4739fa3b 100644 --- a/docs/docs/configuration/record.md +++ b/docs/docs/configuration/record.md @@ -84,3 +84,18 @@ record: ## How do I export recordings? The export page in the Frigate WebUI allows for exporting real time clips with a designated start and stop time as well as exporting a timelapse for a designated start and stop time. These exports can take a while so it is important to leave the file until it is no longer in progress. + +## Syncing Recordings With Disk + +In some cases the recordings files may be deleted but Frigate will not know this has happened. Sync on startup can be enabled which will tell Frigate to check the file system and delete any db entries for files which don't exist. + +```yaml +record: + sync_on_startup: True +``` + +:::warning + +The sync operation uses considerable CPU resources and in most cases is not needed, only enable when necessary. + +::: diff --git a/frigate/config.py b/frigate/config.py index a180bbc9b..bca0ba080 100644 --- a/frigate/config.py +++ b/frigate/config.py @@ -193,6 +193,9 @@ class RecordRetainConfig(FrigateBaseModel): class RecordConfig(FrigateBaseModel): enabled: bool = Field(default=False, title="Enable record on all cameras.") + sync_on_startup: bool = Field( + default=False, title="Sync recordings with disk on startup." + ) expire_interval: int = Field( default=60, title="Number of minutes to wait between cleanup runs.", diff --git a/frigate/record/cleanup.py b/frigate/record/cleanup.py index a48b3fef7..64ec28746 100644 --- a/frigate/record/cleanup.py +++ b/frigate/record/cleanup.py @@ -222,8 +222,9 @@ class RecordingCleanup(threading.Thread): logger.debug("End sync recordings.") def run(self) -> None: - # on startup sync recordings with disk - self.sync_recordings() + # on startup sync recordings with disk if enabled + if self.config.record.sync_on_startup: + self.sync_recordings() # Expire tmp clips every minute, recordings and clean directories every hour. for counter in itertools.cycle(range(self.config.record.expire_interval)):