Skip to content

Commit

Permalink
fix old style recording cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
blakeblackshear committed Oct 23, 2021
1 parent 18f4ab2 commit cd87f3e
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions frigate/record.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,9 +290,7 @@ def expire_files(self):

# find all the recordings older than the oldest recording in the db
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)
oldest_timestamp = p.stat().st_mtime - 1
Expand All @@ -301,7 +299,7 @@ def expire_files(self):

logger.debug(f"Oldest recording in the db: {oldest_timestamp}")
process = sp.run(
["find", RECORD_DIR, "-type", "f", "-newermt", f"@{oldest_timestamp}"],
["find", RECORD_DIR, "-type", "f", "!", "-newermt", f"@{oldest_timestamp}"],
capture_output=True,
text=True,
)
Expand Down

0 comments on commit cd87f3e

Please sign in to comment.