From 26424488a5c72ab0cd404bb3c0f2c4467f7b75b8 Mon Sep 17 00:00:00 2001 From: Blake Blackshear Date: Mon, 23 Aug 2021 07:21:27 -0500 Subject: [PATCH 1/3] use find to reduce CPU usage for legacy expiration --- frigate/record.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/frigate/record.py b/frigate/record.py index 5e51b0ddc..c5150103d 100644 --- a/frigate/record.py +++ b/frigate/record.py @@ -244,6 +244,8 @@ class RecordingCleanup(threading.Thread): def expire_files(self): logger.debug("Start expire files (legacy).") + + shortest_retention = self.config.record.retain_days default_expire = ( datetime.datetime.now().timestamp() - SECONDS_IN_DAY * self.config.record.retain_days @@ -254,8 +256,19 @@ class RecordingCleanup(threading.Thread): datetime.datetime.now().timestamp() - SECONDS_IN_DAY * camera.record.retain_days ) + if camera.record.retain_days < shortest_retention: + shortest_retention = camera.record.retain_days - for p in Path("/media/frigate/recordings").rglob("*.mp4"): + logger.debug(f"Shortest retention: {shortest_retention}") + process = sp.run( + ["find", RECORD_DIR, "-type", "f", "-mtime", f"+{shortest_retention}"], + capture_output=True, + text=True, + ) + files_to_check = process.stdout.splitlines() + + for f in files_to_check: + p = Path(f) # Ignore files that have a record in the recordings DB if Recordings.select().where(Recordings.path == str(p)).count(): continue @@ -265,8 +278,8 @@ class RecordingCleanup(threading.Thread): logger.debug("End expire files (legacy).") def run(self): - # Expire recordings every minute, clean directories every 5 minutes. - for counter in itertools.cycle(range(5)): + # Expire recordings every minute, clean directories every hour. + for counter in itertools.cycle(range(60)): if self.stop_event.wait(60): logger.info(f"Exiting recording cleanup...") break From 5ae4f47e9615b184e53769d8680f35997a579eef Mon Sep 17 00:00:00 2001 From: Bernt Christian Egeland Date: Thu, 19 Aug 2021 18:24:23 +0200 Subject: [PATCH 2/3] removed comma. This was causing the main window to be pulled down behind the headerbar, hence the odd menu behavior --- web/src/AppBar.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/src/AppBar.jsx b/web/src/AppBar.jsx index 8a8183e00..362376874 100644 --- a/web/src/AppBar.jsx +++ b/web/src/AppBar.jsx @@ -63,7 +63,7 @@ export default function AppBar() { - ) : null}, + ) : null} {showDialog ? ( - ) : null}, + ) : null} {showDialogWait ? ( Date: Fri, 20 Aug 2021 13:04:47 +0200 Subject: [PATCH 3/3] reduced navbar padding / height --- web/src/App.jsx | 2 +- web/src/components/AppBar.jsx | 6 +++--- web/src/components/NavigationDrawer.jsx | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/web/src/App.jsx b/web/src/App.jsx index 1212f293f..4ddedece5 100644 --- a/web/src/App.jsx +++ b/web/src/App.jsx @@ -23,7 +23,7 @@ export default function App() { ) : (
-
+
diff --git a/web/src/components/AppBar.jsx b/web/src/components/AppBar.jsx index c35a4ad4a..567fe291d 100644 --- a/web/src/components/AppBar.jsx +++ b/web/src/components/AppBar.jsx @@ -37,13 +37,13 @@ export default function AppBar({ title: Title, overflowRef, onOverflowClick }) { return (
-
@@ -54,7 +54,7 @@ export default function AppBar({ title: Title, overflowRef, onOverflowClick }) {