Skip to content

Commit

Permalink
Reuse CACHE_DIR constant
Browse files Browse the repository at this point in the history
  • Loading branch information
mweinelt committed Jul 27, 2023
1 parent a96602f commit 9be416a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 8 additions & 2 deletions frigate/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@
from tzlocal import get_localzone_name

from frigate.config import FrigateConfig
from frigate.const import CLIPS_DIR, CONFIG_DIR, MAX_SEGMENT_DURATION, RECORD_DIR
from frigate.const import (
CACHE_DIR,
CLIPS_DIR,
CONFIG_DIR,
MAX_SEGMENT_DURATION,
RECORD_DIR,
)
from frigate.events.external import ExternalEventProcessor
from frigate.models import Event, Recordings, Timeline
from frigate.object_processing import TrackedObject
Expand Down Expand Up @@ -1441,7 +1447,7 @@ def recording_clip(camera_name, start_ts, end_ts):
playlist_lines.append(f"outpoint {int(end_ts - clip.start_time)}")

file_name = f"clip_{camera_name}_{start_ts}-{end_ts}.mp4"
path = f"/tmp/cache/{file_name}"
path = os.path.join(CACHE_DIR, file_name)

if not os.path.exists(path):
ffmpeg_cmd = [
Expand Down
4 changes: 2 additions & 2 deletions frigate/record/cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from peewee import DatabaseError, chunked

from frigate.config import FrigateConfig, RetainModeEnum
from frigate.const import RECORD_DIR
from frigate.const import CACHE_DIR, RECORD_DIR
from frigate.models import Event, Recordings, RecordingsToDelete
from frigate.record.util import remove_empty_directories

Expand All @@ -29,7 +29,7 @@ def __init__(self, config: FrigateConfig, stop_event: MpEvent) -> None:

def clean_tmp_clips(self) -> None:
"""delete any clips in the cache that are more than 5 minutes old."""
for p in Path("/tmp/cache").rglob("clip_*.mp4"):
for p in Path(CACHE_DIR).rglob("clip_*.mp4"):
logger.debug(f"Checking tmp clip {p}.")
if p.stat().st_mtime < (datetime.datetime.now().timestamp() - 60 * 1):
logger.debug("Deleting tmp clip.")
Expand Down

0 comments on commit 9be416a

Please sign in to comment.