Reuse CACHE_DIR constant

This commit is contained in:
Martin Weinelt 2023-05-25 02:09:31 +02:00
parent 1e17dbaa91
commit 6a76dca536
No known key found for this signature in database
GPG Key ID: 87C1E9888F856759
2 changed files with 4 additions and 4 deletions

View File

@ -32,7 +32,7 @@ from peewee import SqliteDatabase, operator, fn, DoesNotExist
from playhouse.shortcuts import model_to_dict
from frigate.config import FrigateConfig
from frigate.const import CLIPS_DIR, MAX_SEGMENT_DURATION, RECORD_DIR
from frigate.const import CACHE_DIR, CLIPS_DIR, MAX_SEGMENT_DURATION, RECORD_DIR
from frigate.models import Event, Recordings, Timeline
from frigate.events.external import ExternalEventProcessor
from frigate.object_processing import TrackedObject
@ -1346,7 +1346,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 = [

View File

@ -11,7 +11,7 @@ from peewee import DoesNotExist
from multiprocessing.synchronize import Event as MpEvent
from frigate.config import RetainModeEnum, FrigateConfig
from frigate.const import RECORD_DIR, SECONDS_IN_DAY
from frigate.const import CACHE_DIR, RECORD_DIR, SECONDS_IN_DAY
from frigate.models import Event, Recordings, Timeline
from frigate.record.util import remove_empty_directories
@ -29,7 +29,7 @@ class RecordingCleanup(threading.Thread):
def clean_tmp_clips(self) -> None:
# delete any clips 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.")