Make syncing optional

This commit is contained in:
Nick Mowen 2023-11-17 10:18:38 -07:00
parent 1079796b9e
commit e15e16c680
4 changed files with 13 additions and 10 deletions

View File

@ -350,8 +350,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: Sync recordings with disk on startup and once a day (default: shown below).
sync_recordings: False
# Optional: Retention settings for recording
retain:
# Optional: Number of days to retain recordings regardless of events (default: shown below)

View File

@ -87,11 +87,11 @@ The export page in the Frigate WebUI allows for exporting real time clips with a
## 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.
In some cases the recordings files may be deleted but Frigate will not know this has happened. Recordings sync 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
sync_recordings: True
```
:::warning

View File

@ -259,8 +259,8 @@ class RecordExportConfig(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."
sync_recordings: bool = Field(
default=False, title="Sync recordings with disk on startup and once a day."
)
expire_interval: int = Field(
default=60,

View File

@ -176,10 +176,9 @@ class RecordingCleanup(threading.Thread):
def run(self) -> None:
# on startup sync recordings with disk if enabled
if self.config.record.sync_on_startup:
if self.config.record.sync_recordings:
sync_recordings(limited=False)
next_sync = get_tomorrow_at_time(3)
next_sync = get_tomorrow_at_time(3)
# Expire tmp clips every minute, recordings and clean directories every hour.
for counter in itertools.cycle(range(self.config.record.expire_interval)):
@ -189,7 +188,11 @@ class RecordingCleanup(threading.Thread):
self.clean_tmp_clips()
if datetime.datetime.now().astimezone(datetime.timezone.utc) > next_sync:
if (
self.config.record.sync_recordings
and datetime.datetime.now().astimezone(datetime.timezone.utc)
> next_sync
):
sync_recordings(limited=True)
next_sync = get_tomorrow_at_time(3)