Browse Source

fix old style recording cleanup

Blake Blackshear 3 years ago
parent
commit
cd87f3e6f4
1 changed files with 2 additions and 4 deletions
  1. 2 4
      frigate/record.py

+ 2 - 4
frigate/record.py

@@ -290,9 +290,7 @@ class RecordingCleanup(threading.Thread):
 
 
         # find all the recordings older than the oldest recording in the db
         # find all the recordings older than the oldest recording in the db
         try:
         try:
-            oldest_recording = (
-                Recordings.select().order_by(Recordings.start_time.desc()).get()
-            )
+            oldest_recording = Recordings.select().order_by(Recordings.start_time).get()
 
 
             p = Path(oldest_recording.path)
             p = Path(oldest_recording.path)
             oldest_timestamp = p.stat().st_mtime - 1
             oldest_timestamp = p.stat().st_mtime - 1
@@ -301,7 +299,7 @@ class RecordingCleanup(threading.Thread):
 
 
         logger.debug(f"Oldest recording in the db: {oldest_timestamp}")
         logger.debug(f"Oldest recording in the db: {oldest_timestamp}")
         process = sp.run(
         process = sp.run(
-            ["find", RECORD_DIR, "-type", "f", "-newermt", f"@{oldest_timestamp}"],
+            ["find", RECORD_DIR, "-type", "f", "!", "-newermt", f"@{oldest_timestamp}"],
             capture_output=True,
             capture_output=True,
             text=True,
             text=True,
         )
         )