mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-11-24 22:37:08 +03:00
Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
87b7412dee | ||
|
|
bcd64d96a6 | ||
|
|
0798d3f247 |
Vendored
+81
@@ -4608,6 +4608,14 @@ paths:
|
|||||||
- type: 'null'
|
- type: 'null'
|
||||||
default: 1
|
default: 1
|
||||||
title: Include Thumbnails
|
title: Include Thumbnails
|
||||||
|
- name: favorites
|
||||||
|
in: query
|
||||||
|
required: false
|
||||||
|
schema:
|
||||||
|
anyOf:
|
||||||
|
- type: integer
|
||||||
|
- type: 'null'
|
||||||
|
title: Favorites
|
||||||
- name: min_score
|
- name: min_score
|
||||||
in: query
|
in: query
|
||||||
required: false
|
required: false
|
||||||
@@ -5138,6 +5146,75 @@ paths:
|
|||||||
security:
|
security:
|
||||||
- frigateAdminAuth: []
|
- frigateAdminAuth: []
|
||||||
x-required-role: admin
|
x-required-role: admin
|
||||||
|
/events/{event_id}/retain:
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- Events
|
||||||
|
summary: Set event retain indefinitely.
|
||||||
|
description: |-
|
||||||
|
**Access:** Admin role required.
|
||||||
|
|
||||||
|
Sets an event to retain indefinitely.
|
||||||
|
Returns a success message or an error if the event is not found.
|
||||||
|
NOTE: This is a legacy endpoint and is not supported in the frontend.
|
||||||
|
operationId: set_retain_events__event_id__retain_post
|
||||||
|
parameters:
|
||||||
|
- name: event_id
|
||||||
|
in: path
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
title: Event Id
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: Successful Response
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/GenericResponse'
|
||||||
|
'422':
|
||||||
|
description: Validation Error
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/HTTPValidationError'
|
||||||
|
security:
|
||||||
|
- frigateAdminAuth: []
|
||||||
|
x-required-role: admin
|
||||||
|
delete:
|
||||||
|
tags:
|
||||||
|
- Events
|
||||||
|
summary: Stop event from being retained indefinitely
|
||||||
|
description: |-
|
||||||
|
**Access:** Admin role required.
|
||||||
|
|
||||||
|
Stops an event from being retained indefinitely.
|
||||||
|
Returns a success message or an error if the event is not found.
|
||||||
|
NOTE: This is a legacy endpoint and is not supported in the frontend.
|
||||||
|
operationId: delete_retain_events__event_id__retain_delete
|
||||||
|
parameters:
|
||||||
|
- name: event_id
|
||||||
|
in: path
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
title: Event Id
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: Successful Response
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/GenericResponse'
|
||||||
|
'422':
|
||||||
|
description: Validation Error
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/HTTPValidationError'
|
||||||
|
security:
|
||||||
|
- frigateAdminAuth: []
|
||||||
|
x-required-role: admin
|
||||||
/events/{event_id}/plus:
|
/events/{event_id}/plus:
|
||||||
post:
|
post:
|
||||||
tags:
|
tags:
|
||||||
@@ -8378,6 +8455,9 @@ components:
|
|||||||
has_snapshot:
|
has_snapshot:
|
||||||
type: boolean
|
type: boolean
|
||||||
title: Has Snapshot
|
title: Has Snapshot
|
||||||
|
retain_indefinitely:
|
||||||
|
type: boolean
|
||||||
|
title: Retain Indefinitely
|
||||||
plus_id:
|
plus_id:
|
||||||
anyOf:
|
anyOf:
|
||||||
- type: string
|
- type: string
|
||||||
@@ -8415,6 +8495,7 @@ components:
|
|||||||
- thumbnail
|
- thumbnail
|
||||||
- has_clip
|
- has_clip
|
||||||
- has_snapshot
|
- has_snapshot
|
||||||
|
- retain_indefinitely
|
||||||
- plus_id
|
- plus_id
|
||||||
- model_hash
|
- model_hash
|
||||||
- detector_type
|
- detector_type
|
||||||
|
|||||||
+29
-16
@@ -74,7 +74,7 @@ from frigate.util.config import (
|
|||||||
find_config_file,
|
find_config_file,
|
||||||
redact_credential,
|
redact_credential,
|
||||||
)
|
)
|
||||||
from frigate.util.env import substitute_frigate_vars
|
from frigate.util.env import candidate_env_vars, substitute_frigate_vars
|
||||||
from frigate.util.live_streams import (
|
from frigate.util.live_streams import (
|
||||||
generated_transcode_streams,
|
generated_transcode_streams,
|
||||||
sync_transcode_streams,
|
sync_transcode_streams,
|
||||||
@@ -589,14 +589,18 @@ def config_raw():
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def _go2rtc_config(raw_config: str) -> dict[str, Any]:
|
def _go2rtc_config(raw_config: str) -> tuple[dict[str, Any], Any]:
|
||||||
"""Load the go2rtc section with the same loader Frigate and go2rtc startup use.
|
"""Load the go2rtc section and environment_vars with the same loader Frigate
|
||||||
|
and go2rtc startup use.
|
||||||
|
|
||||||
Raises ruamel.yaml.YAMLError when the config cannot be parsed.
|
Raises ruamel.yaml.YAMLError when the config cannot be parsed.
|
||||||
"""
|
"""
|
||||||
loaded = ruamel.yaml.YAML().load(raw_config)
|
loaded = ruamel.yaml.YAML().load(raw_config)
|
||||||
go2rtc = loaded.get("go2rtc") if isinstance(loaded, dict) else None
|
if not isinstance(loaded, dict):
|
||||||
return go2rtc if isinstance(go2rtc, dict) else {}
|
return {}, None
|
||||||
|
|
||||||
|
go2rtc = loaded.get("go2rtc")
|
||||||
|
return go2rtc if isinstance(go2rtc, dict) else {}, loaded.get("environment_vars")
|
||||||
|
|
||||||
|
|
||||||
def _restricted_go2rtc_response(
|
def _restricted_go2rtc_response(
|
||||||
@@ -608,7 +612,7 @@ def _restricted_go2rtc_response(
|
|||||||
otherwise load them from the saved config on the next restart.
|
otherwise load them from the saved config on the next restart.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
new_go2rtc = _go2rtc_config(new_raw_config)
|
new_go2rtc, new_env_vars = _go2rtc_config(new_raw_config)
|
||||||
except ruamel.yaml.YAMLError:
|
except ruamel.yaml.YAMLError:
|
||||||
logger.warning("Rejected config change that could not be parsed")
|
logger.warning("Rejected config change that could not be parsed")
|
||||||
return JSONResponse(
|
return JSONResponse(
|
||||||
@@ -617,13 +621,13 @@ def _restricted_go2rtc_response(
|
|||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
old_go2rtc = _go2rtc_config(old_raw_config)
|
old_go2rtc, _ = _go2rtc_config(old_raw_config)
|
||||||
except ruamel.yaml.YAMLError:
|
except ruamel.yaml.YAMLError:
|
||||||
# with no readable saved config, every source is treated as new
|
# with no readable saved config, every source is treated as new
|
||||||
old_go2rtc = {}
|
old_go2rtc = {}
|
||||||
|
|
||||||
issues = find_restricted_go2rtc_stream_changes(
|
issues = find_restricted_go2rtc_stream_changes(
|
||||||
old_go2rtc.get("streams"), new_go2rtc.get("streams")
|
old_go2rtc.get("streams"), new_go2rtc.get("streams"), new_env_vars
|
||||||
)
|
)
|
||||||
exec_keys = find_restricted_go2rtc_exec_changes(old_go2rtc, new_go2rtc)
|
exec_keys = find_restricted_go2rtc_exec_changes(old_go2rtc, new_go2rtc)
|
||||||
if not issues and not exec_keys:
|
if not issues and not exec_keys:
|
||||||
@@ -787,16 +791,20 @@ def config_save(save_option: str, body: Any = Body(media_type="text/plain")):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def _restore_masked_camera_paths(config_data: dict, saved: dict) -> str | None:
|
def _restore_masked_camera_paths(
|
||||||
|
config_data: dict, saved: dict, shown_env_vars: dict[str, str]
|
||||||
|
) -> str | None:
|
||||||
"""Substitute incoming masked camera paths with the saved ones.
|
"""Substitute incoming masked camera paths with the saved ones.
|
||||||
|
|
||||||
The /config response masks ffmpeg input credentials, so the settings UI
|
The /config response masks ffmpeg input credentials, so the settings UI
|
||||||
sends the masked path back when sibling fields (e.g. hwaccel_args) are
|
sends the masked path back when sibling fields (e.g. hwaccel_args) are
|
||||||
edited. Each masked path is matched to the saved input that masks to the
|
edited. Each masked path is matched to the saved input that masks to the
|
||||||
same value, with roles breaking a tie, so deleting or reordering inputs
|
same value, with roles breaking a tie, so deleting or reordering inputs
|
||||||
keeps each path's own credentials. The saved path is restored as written,
|
keeps each path's own credentials. Saved paths resolve with
|
||||||
keeping any {FRIGATE_*} placeholder. Mutates `config_data` in place and
|
`shown_env_vars`, the block the running config and /config used. The saved
|
||||||
returns an error message when a masked path has no single match.
|
path is restored as written, keeping any {FRIGATE_*} placeholder. Mutates
|
||||||
|
`config_data` in place and returns an error message when a masked path has
|
||||||
|
no single match.
|
||||||
"""
|
"""
|
||||||
cameras = config_data.get("cameras")
|
cameras = config_data.get("cameras")
|
||||||
if not isinstance(cameras, dict):
|
if not isinstance(cameras, dict):
|
||||||
@@ -832,10 +840,12 @@ def _restore_masked_camera_paths(config_data: dict, saved: dict) -> str | None:
|
|||||||
path = input_obj.get("path")
|
path = input_obj.get("path")
|
||||||
if not isinstance(path, str) or not is_masked_camera_path(path):
|
if not isinstance(path, str) or not is_masked_camera_path(path):
|
||||||
continue
|
continue
|
||||||
|
with candidate_env_vars(shown_env_vars):
|
||||||
candidates = [
|
candidates = [
|
||||||
inp
|
inp
|
||||||
for inp in saved_inputs
|
for inp in saved_inputs
|
||||||
if clean_camera_user_pass(_resolve_frigate_vars(inp["path"])) == path
|
if clean_camera_user_pass(_resolve_frigate_vars(inp["path"]))
|
||||||
|
== path
|
||||||
]
|
]
|
||||||
if len({inp["path"] for inp in candidates}) > 1:
|
if len({inp["path"] for inp in candidates}) > 1:
|
||||||
candidates = [
|
candidates = [
|
||||||
@@ -880,14 +890,14 @@ def _saved_config_from_memory(config: FrigateConfig) -> dict[str, Any]:
|
|||||||
|
|
||||||
|
|
||||||
def _config_data_to_updates(
|
def _config_data_to_updates(
|
||||||
config_data: dict, saved: dict[str, Any]
|
config_data: dict, saved: dict[str, Any], running: FrigateConfig
|
||||||
) -> tuple[dict[str, Any], str | None]:
|
) -> tuple[dict[str, Any], str | None]:
|
||||||
"""Flatten a /config/set payload after restoring masked credentials.
|
"""Flatten a /config/set payload after restoring masked credentials.
|
||||||
|
|
||||||
`saved` is the config the masked values were taken from. Returns the flat
|
`saved` is the config the masked values were taken from. Returns the flat
|
||||||
updates, or an error message when a masked value can't be restored.
|
updates, or an error message when a masked value can't be restored.
|
||||||
"""
|
"""
|
||||||
error = _restore_masked_camera_paths(config_data, saved)
|
error = _restore_masked_camera_paths(config_data, saved, running.environment_vars)
|
||||||
if error:
|
if error:
|
||||||
return {}, error
|
return {}, error
|
||||||
|
|
||||||
@@ -941,7 +951,9 @@ def _config_set_in_memory(request: Request, body: AppConfigSetBody) -> JSONRespo
|
|||||||
updates = {}
|
updates = {}
|
||||||
if body.config_data:
|
if body.config_data:
|
||||||
updates, error = _config_data_to_updates(
|
updates, error = _config_data_to_updates(
|
||||||
body.config_data, _saved_config_from_memory(request.app.frigate_config)
|
body.config_data,
|
||||||
|
_saved_config_from_memory(request.app.frigate_config),
|
||||||
|
request.app.frigate_config,
|
||||||
)
|
)
|
||||||
if error:
|
if error:
|
||||||
return JSONResponse(
|
return JSONResponse(
|
||||||
@@ -1122,6 +1134,7 @@ def config_set(request: Request, body: AppConfigSetBody):
|
|||||||
updates, error = _config_data_to_updates(
|
updates, error = _config_data_to_updates(
|
||||||
body.config_data,
|
body.config_data,
|
||||||
saved_config if isinstance(saved_config, dict) else {},
|
saved_config if isinstance(saved_config, dict) else {},
|
||||||
|
request.app.frigate_config,
|
||||||
)
|
)
|
||||||
|
|
||||||
if error:
|
if error:
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ class EventsQueryParams(BaseModel):
|
|||||||
),
|
),
|
||||||
deprecated=True,
|
deprecated=True,
|
||||||
)
|
)
|
||||||
|
favorites: int | None = None
|
||||||
min_score: float | None = None
|
min_score: float | None = None
|
||||||
max_score: float | None = None
|
max_score: float | None = None
|
||||||
min_speed: float | None = None
|
min_speed: float | None = None
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ class EventResponse(BaseModel):
|
|||||||
thumbnail: str | None
|
thumbnail: str | None
|
||||||
has_clip: bool
|
has_clip: bool
|
||||||
has_snapshot: bool
|
has_snapshot: bool
|
||||||
|
retain_indefinitely: bool
|
||||||
plus_id: str | None
|
plus_id: str | None
|
||||||
model_hash: str | None
|
model_hash: str | None
|
||||||
detector_type: str | None
|
detector_type: str | None
|
||||||
|
|||||||
@@ -142,6 +142,7 @@ def events(
|
|||||||
has_snapshot = params.has_snapshot
|
has_snapshot = params.has_snapshot
|
||||||
in_progress = params.in_progress
|
in_progress = params.in_progress
|
||||||
include_thumbnails = params.include_thumbnails
|
include_thumbnails = params.include_thumbnails
|
||||||
|
favorites = params.favorites
|
||||||
min_score = params.min_score
|
min_score = params.min_score
|
||||||
max_score = params.max_score
|
max_score = params.max_score
|
||||||
min_speed = params.min_speed
|
min_speed = params.min_speed
|
||||||
@@ -166,6 +167,7 @@ def events(
|
|||||||
Event.has_clip,
|
Event.has_clip,
|
||||||
Event.has_snapshot,
|
Event.has_snapshot,
|
||||||
Event.plus_id,
|
Event.plus_id,
|
||||||
|
Event.retain_indefinitely,
|
||||||
Event.sub_label,
|
Event.sub_label,
|
||||||
Event.top_score,
|
Event.top_score,
|
||||||
Event.false_positive,
|
Event.false_positive,
|
||||||
@@ -310,6 +312,9 @@ def events(
|
|||||||
if include_thumbnails:
|
if include_thumbnails:
|
||||||
selected_columns.append(Event.thumbnail)
|
selected_columns.append(Event.thumbnail)
|
||||||
|
|
||||||
|
if favorites:
|
||||||
|
clauses.append(Event.retain_indefinitely == favorites)
|
||||||
|
|
||||||
if max_score is not None:
|
if max_score is not None:
|
||||||
clauses.append(Event.data["score"] <= max_score)
|
clauses.append(Event.data["score"] <= max_score)
|
||||||
|
|
||||||
@@ -410,6 +415,7 @@ def events_explore(
|
|||||||
Event.has_clip,
|
Event.has_clip,
|
||||||
Event.has_snapshot,
|
Event.has_snapshot,
|
||||||
Event.plus_id,
|
Event.plus_id,
|
||||||
|
Event.retain_indefinitely,
|
||||||
Event.top_score,
|
Event.top_score,
|
||||||
Event.false_positive,
|
Event.false_positive,
|
||||||
Event.box,
|
Event.box,
|
||||||
@@ -450,6 +456,7 @@ def events_explore(
|
|||||||
"has_clip": event.has_clip,
|
"has_clip": event.has_clip,
|
||||||
"has_snapshot": event.has_snapshot,
|
"has_snapshot": event.has_snapshot,
|
||||||
"plus_id": event.plus_id,
|
"plus_id": event.plus_id,
|
||||||
|
"retain_indefinitely": event.retain_indefinitely,
|
||||||
"sub_label": event.sub_label,
|
"sub_label": event.sub_label,
|
||||||
"top_score": event.top_score,
|
"top_score": event.top_score,
|
||||||
"false_positive": event.false_positive,
|
"false_positive": event.false_positive,
|
||||||
@@ -1024,6 +1031,34 @@ async def event(event_id: str, request: Request):
|
|||||||
return JSONResponse(content="Event not found", status_code=404)
|
return JSONResponse(content="Event not found", status_code=404)
|
||||||
|
|
||||||
|
|
||||||
|
@router.post(
|
||||||
|
"/events/{event_id}/retain",
|
||||||
|
response_model=GenericResponse,
|
||||||
|
dependencies=[Depends(require_role(["admin"]))],
|
||||||
|
summary="Set event retain indefinitely.",
|
||||||
|
description="""Sets an event to retain indefinitely.
|
||||||
|
Returns a success message or an error if the event is not found.
|
||||||
|
NOTE: This is a legacy endpoint and is not supported in the frontend.
|
||||||
|
""",
|
||||||
|
)
|
||||||
|
def set_retain(event_id: str):
|
||||||
|
try:
|
||||||
|
event = Event.get(Event.id == event_id)
|
||||||
|
except DoesNotExist:
|
||||||
|
return JSONResponse(
|
||||||
|
content=({"success": False, "message": "Event " + event_id + " not found"}),
|
||||||
|
status_code=404,
|
||||||
|
)
|
||||||
|
|
||||||
|
event.retain_indefinitely = True
|
||||||
|
event.save()
|
||||||
|
|
||||||
|
return JSONResponse(
|
||||||
|
content=({"success": True, "message": "Event " + event_id + " retained"}),
|
||||||
|
status_code=200,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@router.post(
|
@router.post(
|
||||||
"/events/{event_id}/plus",
|
"/events/{event_id}/plus",
|
||||||
response_model=EventUploadPlusResponse,
|
response_model=EventUploadPlusResponse,
|
||||||
@@ -1269,6 +1304,35 @@ async def false_positive(request: Request, event_id: str):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@router.delete(
|
||||||
|
"/events/{event_id}/retain",
|
||||||
|
response_model=GenericResponse,
|
||||||
|
dependencies=[Depends(require_role(["admin"]))],
|
||||||
|
summary="Stop event from being retained indefinitely",
|
||||||
|
description="""Stops an event from being retained indefinitely.
|
||||||
|
Returns a success message or an error if the event is not found.
|
||||||
|
NOTE: This is a legacy endpoint and is not supported in the frontend.
|
||||||
|
""",
|
||||||
|
)
|
||||||
|
async def delete_retain(event_id: str, request: Request):
|
||||||
|
try:
|
||||||
|
event = Event.get(Event.id == event_id)
|
||||||
|
await require_camera_access(event.camera, request=request)
|
||||||
|
except DoesNotExist:
|
||||||
|
return JSONResponse(
|
||||||
|
content=({"success": False, "message": "Event " + event_id + " not found"}),
|
||||||
|
status_code=404,
|
||||||
|
)
|
||||||
|
|
||||||
|
event.retain_indefinitely = False
|
||||||
|
event.save()
|
||||||
|
|
||||||
|
return JSONResponse(
|
||||||
|
content=({"success": True, "message": "Event " + event_id + " un-retained"}),
|
||||||
|
status_code=200,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@router.post(
|
@router.post(
|
||||||
"/events/{event_id}/sub_label",
|
"/events/{event_id}/sub_label",
|
||||||
response_model=GenericResponse,
|
response_model=GenericResponse,
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ from urllib.parse import unquote
|
|||||||
from peewee import DoesNotExist, Field
|
from peewee import DoesNotExist, Field
|
||||||
|
|
||||||
from frigate.config import FrigateConfig
|
from frigate.config import FrigateConfig
|
||||||
from frigate.const import CLIPS_DIR, EXPORT_DIR, SUB_CACHE_TAG
|
from frigate.const import CLIPS_DIR, EXPORT_DIR
|
||||||
from frigate.models import Export, User
|
from frigate.models import Export, User
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@@ -137,12 +137,11 @@ def _resolve_recording(
|
|||||||
# /recordings/{date} → neutral
|
# /recordings/{date} → neutral
|
||||||
# /recordings/{date}/{hour} → multi-camera listing
|
# /recordings/{date}/{hour} → multi-camera listing
|
||||||
# /recordings/{date}/{hour}/{cam}/... → camera
|
# /recordings/{date}/{hour}/{cam}/... → camera
|
||||||
# /recordings/{date}/{hour}/{cam}@sub/... → camera (sub stream)
|
|
||||||
if len(parts) <= 2:
|
if len(parts) <= 2:
|
||||||
return MediaAuthResolution.LISTING_NEUTRAL, None
|
return MediaAuthResolution.LISTING_NEUTRAL, None
|
||||||
if len(parts) == 3:
|
if len(parts) == 3:
|
||||||
return MediaAuthResolution.LISTING_MULTI_CAMERA, None
|
return MediaAuthResolution.LISTING_MULTI_CAMERA, None
|
||||||
return MediaAuthResolution.CAMERA, parts[3].removesuffix(SUB_CACHE_TAG)
|
return MediaAuthResolution.CAMERA, parts[3]
|
||||||
|
|
||||||
|
|
||||||
def _resolve_clip(
|
def _resolve_clip(
|
||||||
@@ -151,7 +150,6 @@ def _resolve_clip(
|
|||||||
# /clips → multi-camera listing
|
# /clips → multi-camera listing
|
||||||
# /clips/thumbs/{cam}/... → camera
|
# /clips/thumbs/{cam}/... → camera
|
||||||
# /clips/previews/{cam}/... → camera
|
# /clips/previews/{cam}/... → camera
|
||||||
# /clips/triggers/{cam}/... → camera
|
|
||||||
# /clips/review/thumb-{cam}-{review_id}.webp → camera (parsed)
|
# /clips/review/thumb-{cam}-{review_id}.webp → camera (parsed)
|
||||||
# /clips/export/{export_id}.{ext} → camera (DB lookup)
|
# /clips/export/{export_id}.{ext} → camera (DB lookup)
|
||||||
# /clips/faces/... → admin-only
|
# /clips/faces/... → admin-only
|
||||||
@@ -165,7 +163,7 @@ def _resolve_clip(
|
|||||||
|
|
||||||
second = parts[1]
|
second = parts[1]
|
||||||
|
|
||||||
if second in ("thumbs", "previews", "triggers"):
|
if second in ("thumbs", "previews"):
|
||||||
if len(parts) == 2:
|
if len(parts) == 2:
|
||||||
return MediaAuthResolution.LISTING_MULTI_CAMERA, None
|
return MediaAuthResolution.LISTING_MULTI_CAMERA, None
|
||||||
return MediaAuthResolution.CAMERA, parts[2]
|
return MediaAuthResolution.CAMERA, parts[2]
|
||||||
|
|||||||
@@ -685,7 +685,7 @@ class WebPushClient(Communicator):
|
|||||||
|
|
||||||
title = f"{name.replace('_', ' ')} triggered on {camera_name}"
|
title = f"{name.replace('_', ' ')} triggered on {camera_name}"
|
||||||
message = f"{titlecase(trigger_type)} trigger fired for {camera_name} with score {score:.2f}"
|
message = f"{titlecase(trigger_type)} trigger fired for {camera_name} with score {score:.2f}"
|
||||||
image = f"api/events/{event_id}/thumbnail.webp"
|
image = f"clips/triggers/{camera}/{event_id}.webp"
|
||||||
|
|
||||||
direct_url = f"/explore?event_id={event_id}"
|
direct_url = f"/explore?event_id={event_id}"
|
||||||
ttl = 0
|
ttl = 0
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import io
|
|||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
from collections.abc import Mapping
|
||||||
from typing import Any, Self
|
from typing import Any, Self
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
@@ -34,7 +35,7 @@ from frigate.util.config import (
|
|||||||
get_relative_coordinates,
|
get_relative_coordinates,
|
||||||
migrate_frigate_config,
|
migrate_frigate_config,
|
||||||
)
|
)
|
||||||
from frigate.util.env import EnvVars, reload_sources
|
from frigate.util.env import EnvVars, candidate_env_vars, reload_sources
|
||||||
from frigate.util.image import create_mask
|
from frigate.util.image import create_mask
|
||||||
from frigate.util.live_streams import (
|
from frigate.util.live_streams import (
|
||||||
default_transcode_source,
|
default_transcode_source,
|
||||||
@@ -1566,6 +1567,12 @@ class FrigateConfig(FrigateBaseModel):
|
|||||||
def parse_object(
|
def parse_object(
|
||||||
cls, obj: Any, *, plus_api: PlusApi | None = None, install: bool = False
|
cls, obj: Any, *, plus_api: PlusApi | None = None, install: bool = False
|
||||||
):
|
):
|
||||||
return cls.model_validate(
|
context = {"plus_api": plus_api, "install": install}
|
||||||
obj, context={"plus_api": plus_api, "install": install}
|
|
||||||
)
|
if install:
|
||||||
|
return cls.model_validate(obj, context=context)
|
||||||
|
|
||||||
|
# a candidate config resolves placeholders against its own block
|
||||||
|
env_vars = obj.get("environment_vars") if isinstance(obj, Mapping) else None
|
||||||
|
with candidate_env_vars(env_vars):
|
||||||
|
return cls.model_validate(obj, context=context)
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ class EventCleanup(threading.Thread):
|
|||||||
Event.camera.not_in(self.camera_keys),
|
Event.camera.not_in(self.camera_keys),
|
||||||
Event.start_time < expire_after,
|
Event.start_time < expire_after,
|
||||||
Event.label == event.label,
|
Event.label == event.label,
|
||||||
|
Event.retain_indefinitely == False,
|
||||||
Event.has_snapshot == True,
|
Event.has_snapshot == True,
|
||||||
)
|
)
|
||||||
.namedtuples()
|
.namedtuples()
|
||||||
@@ -110,6 +111,7 @@ class EventCleanup(threading.Thread):
|
|||||||
Event.camera.not_in(self.camera_keys),
|
Event.camera.not_in(self.camera_keys),
|
||||||
Event.start_time < expire_after,
|
Event.start_time < expire_after,
|
||||||
Event.label == event.label,
|
Event.label == event.label,
|
||||||
|
Event.retain_indefinitely == False,
|
||||||
Event.has_snapshot == True,
|
Event.has_snapshot == True,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -165,6 +167,7 @@ class EventCleanup(threading.Thread):
|
|||||||
Event.camera == name,
|
Event.camera == name,
|
||||||
Event.start_time < expire_after,
|
Event.start_time < expire_after,
|
||||||
Event.label == event.label,
|
Event.label == event.label,
|
||||||
|
Event.retain_indefinitely == False,
|
||||||
Event.has_snapshot == True,
|
Event.has_snapshot == True,
|
||||||
)
|
)
|
||||||
.namedtuples()
|
.namedtuples()
|
||||||
@@ -209,6 +212,7 @@ class EventCleanup(threading.Thread):
|
|||||||
query = Event.select(Event.id).where(
|
query = Event.select(Event.id).where(
|
||||||
Event.camera.not_in(self.camera_keys),
|
Event.camera.not_in(self.camera_keys),
|
||||||
Event.start_time < expire_after,
|
Event.start_time < expire_after,
|
||||||
|
Event.retain_indefinitely == False,
|
||||||
Event.has_clip == True,
|
Event.has_clip == True,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -254,6 +258,7 @@ class EventCleanup(threading.Thread):
|
|||||||
)
|
)
|
||||||
.where(
|
.where(
|
||||||
Event.camera == name,
|
Event.camera == name,
|
||||||
|
Event.retain_indefinitely == False,
|
||||||
Event.has_clip == True,
|
Event.has_clip == True,
|
||||||
(
|
(
|
||||||
(
|
(
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ class Event(Model):
|
|||||||
area = (
|
area = (
|
||||||
IntegerField()
|
IntegerField()
|
||||||
) # TODO remove when columns can be dropped without rebuilding table
|
) # TODO remove when columns can be dropped without rebuilding table
|
||||||
|
retain_indefinitely = BooleanField(default=False)
|
||||||
ratio = FloatField(
|
ratio = FloatField(
|
||||||
default=1.0
|
default=1.0
|
||||||
) # TODO remove when columns can be dropped without rebuilding table
|
) # TODO remove when columns can be dropped without rebuilding table
|
||||||
|
|||||||
+69
-1
@@ -260,12 +260,53 @@ class StorageMaintainer(threading.Thread):
|
|||||||
.iterator()
|
.iterator()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
retained_events = (
|
||||||
|
Event.select(
|
||||||
|
Event.start_time,
|
||||||
|
Event.end_time,
|
||||||
|
)
|
||||||
|
.where(
|
||||||
|
Event.retain_indefinitely == True,
|
||||||
|
Event.has_clip,
|
||||||
|
)
|
||||||
|
.order_by(Event.start_time.asc())
|
||||||
|
.namedtuples()
|
||||||
|
)
|
||||||
|
|
||||||
|
event_start = 0
|
||||||
deleted_recordings = []
|
deleted_recordings = []
|
||||||
for recording in recordings:
|
for recording in recordings:
|
||||||
# check if 1 hour of storage has been reclaimed
|
# check if 1 hour of storage has been reclaimed
|
||||||
if deleted_segments_size > hourly_bandwidth:
|
if deleted_segments_size > hourly_bandwidth:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
keep = False
|
||||||
|
|
||||||
|
# Now look for a reason to keep this recording segment
|
||||||
|
for idx in range(event_start, len(retained_events)):
|
||||||
|
event = retained_events[idx]
|
||||||
|
|
||||||
|
# if the event starts in the future, stop checking events
|
||||||
|
# and let this recording segment expire
|
||||||
|
if event.start_time > recording.end_time:
|
||||||
|
keep = False
|
||||||
|
break
|
||||||
|
|
||||||
|
# if the event is in progress or ends after the recording starts, keep it
|
||||||
|
# and stop looking at events
|
||||||
|
if event.end_time is None or event.end_time >= recording.start_time:
|
||||||
|
keep = True
|
||||||
|
break
|
||||||
|
|
||||||
|
# if the event ends before this recording segment starts, skip
|
||||||
|
# this event and check the next event for an overlap.
|
||||||
|
# since the events and recordings are sorted, we can skip events
|
||||||
|
# that end before the previous recording segment started on future segments
|
||||||
|
if event.end_time < recording.start_time:
|
||||||
|
event_start = idx
|
||||||
|
|
||||||
|
# Delete recordings not retained indefinitely
|
||||||
|
if not keep:
|
||||||
try:
|
try:
|
||||||
clear_and_unlink(Path(recording.path), missing_ok=False)
|
clear_and_unlink(Path(recording.path), missing_ok=False)
|
||||||
deleted_recordings.append(recording)
|
deleted_recordings.append(recording)
|
||||||
@@ -274,10 +315,37 @@ class StorageMaintainer(threading.Thread):
|
|||||||
# this file was not found so we must assume no space was cleaned up
|
# this file was not found so we must assume no space was cleaned up
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
# check if need to delete retained segments
|
||||||
if deleted_segments_size < hourly_bandwidth:
|
if deleted_segments_size < hourly_bandwidth:
|
||||||
logger.error(
|
logger.error(
|
||||||
f"Could not clear {hourly_bandwidth} MB, currently {deleted_segments_size:.2f} MB have been cleared."
|
f"Could not clear {hourly_bandwidth} MB, currently {deleted_segments_size:.2f} MB have been cleared. Retained recordings must be deleted."
|
||||||
)
|
)
|
||||||
|
recordings = (
|
||||||
|
Recordings.select(
|
||||||
|
Recordings.id,
|
||||||
|
Recordings.camera,
|
||||||
|
Recordings.start_time,
|
||||||
|
Recordings.end_time,
|
||||||
|
Recordings.path,
|
||||||
|
Recordings.segment_size,
|
||||||
|
)
|
||||||
|
.order_by(Recordings.start_time.asc())
|
||||||
|
.namedtuples()
|
||||||
|
.iterator()
|
||||||
|
)
|
||||||
|
|
||||||
|
for recording in recordings:
|
||||||
|
if deleted_segments_size > hourly_bandwidth:
|
||||||
|
break
|
||||||
|
|
||||||
|
try:
|
||||||
|
clear_and_unlink(Path(recording.path), missing_ok=False)
|
||||||
|
deleted_segments_size += recording.segment_size
|
||||||
|
deleted_recordings.append(recording)
|
||||||
|
except FileNotFoundError:
|
||||||
|
# this file was not found so we must assume no space was cleaned up
|
||||||
|
pass
|
||||||
|
|
||||||
self.retention_unmet = True
|
self.retention_unmet = True
|
||||||
else:
|
else:
|
||||||
logger.info(f"Cleaned up {deleted_segments_size:.2f} MB of recordings")
|
logger.info(f"Cleaned up {deleted_segments_size:.2f} MB of recordings")
|
||||||
|
|||||||
@@ -10,7 +10,13 @@ import ruamel.yaml
|
|||||||
|
|
||||||
from frigate.models import Event, Recordings, ReviewSegment
|
from frigate.models import Event, Recordings, ReviewSegment
|
||||||
from frigate.test.http_api.base_http_test import AuthTestClient, BaseTestHttp
|
from frigate.test.http_api.base_http_test import AuthTestClient, BaseTestHttp
|
||||||
from frigate.util.env import _CONTAINER_ENV, FRIGATE_ENV_VARS, reload_sources
|
from frigate.util.env import (
|
||||||
|
_CONFIG_ENV_VARS,
|
||||||
|
_CONTAINER_ENV,
|
||||||
|
FRIGATE_ENV_VARS,
|
||||||
|
apply_config_env_vars,
|
||||||
|
reload_sources,
|
||||||
|
)
|
||||||
|
|
||||||
# shape of the source in GHSA-qjjw-3v66-279f, with the payload replaced
|
# shape of the source in GHSA-qjjw-3v66-279f, with the payload replaced
|
||||||
_INJECTED_SRC = "ffmpeg:#input='-f''h264''-i''data:placeholder''-c''copy'"
|
_INJECTED_SRC = "ffmpeg:#input='-f''h264''-i''data:placeholder''-c''copy'"
|
||||||
@@ -18,6 +24,8 @@ _INJECTED_SRC = "ffmpeg:#input='-f''h264''-i''data:placeholder''-c''copy'"
|
|||||||
# an unrestricted ffmpeg: source the operator already has in the file on disk
|
# an unrestricted ffmpeg: source the operator already has in the file on disk
|
||||||
_EXISTING_SRC = "ffmpeg:rtsp://10.0.0.1:554/video#raw=-vn"
|
_EXISTING_SRC = "ffmpeg:rtsp://10.0.0.1:554/video#raw=-vn"
|
||||||
|
|
||||||
|
_PLACEHOLDER_SRC = "ffmpeg:rtsp://10.0.0.1:554/{FRIGATE_CAM_PATH}"
|
||||||
|
|
||||||
_CONFIG = {
|
_CONFIG = {
|
||||||
"mqtt": {"host": "mqtt"},
|
"mqtt": {"host": "mqtt"},
|
||||||
"go2rtc": {"streams": {"front_door": [_EXISTING_SRC]}},
|
"go2rtc": {"streams": {"front_door": [_EXISTING_SRC]}},
|
||||||
@@ -111,6 +119,28 @@ class TestConfigGo2rtcStreamRestrictions(BaseTestHttp):
|
|||||||
headers={"Content-Type": "text/plain"},
|
headers={"Content-Type": "text/plain"},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def _save(self, config: dict):
|
||||||
|
with AuthTestClient(self.app) as client:
|
||||||
|
return client.post(
|
||||||
|
"/config/save?save_option=saveonly",
|
||||||
|
content=_dump(config),
|
||||||
|
headers={"Content-Type": "text/plain"},
|
||||||
|
)
|
||||||
|
|
||||||
|
def _start_with_placeholder_source(self) -> dict:
|
||||||
|
"""Write and install a config whose stream reads FRIGATE_CAM_PATH from
|
||||||
|
environment_vars, as if Frigate had started with it."""
|
||||||
|
config = copy.deepcopy(_CONFIG)
|
||||||
|
config["environment_vars"] = {"FRIGATE_CAM_PATH": "video"}
|
||||||
|
config["go2rtc"]["streams"]["front_door"].append(_PLACEHOLDER_SRC)
|
||||||
|
with open(self.config_path, "w") as f:
|
||||||
|
f.write(_dump(config))
|
||||||
|
|
||||||
|
apply_config_env_vars(config["environment_vars"])
|
||||||
|
self.addCleanup(reload_sources, warn=False)
|
||||||
|
self.addCleanup(_CONFIG_ENV_VARS.clear)
|
||||||
|
return config
|
||||||
|
|
||||||
# --- config/set ---
|
# --- config/set ---
|
||||||
|
|
||||||
def test_set_rejects_injected_ffmpeg_source(self):
|
def test_set_rejects_injected_ffmpeg_source(self):
|
||||||
@@ -255,6 +285,52 @@ class TestConfigGo2rtcStreamRestrictions(BaseTestHttp):
|
|||||||
assert resp.status_code == 200, resp.text
|
assert resp.status_code == 200, resp.text
|
||||||
assert src in self._read_config()
|
assert src in self._read_config()
|
||||||
|
|
||||||
|
def test_save_rejects_changed_env_var_in_existing_source(self):
|
||||||
|
config = self._start_with_placeholder_source()
|
||||||
|
before = self._read_config()
|
||||||
|
config["environment_vars"]["FRIGATE_CAM_PATH"] = "video#raw=-vn"
|
||||||
|
resp = self._save(config)
|
||||||
|
assert resp.status_code == 400
|
||||||
|
assert "Restricted go2rtc stream source" in resp.json()["message"]
|
||||||
|
assert self._read_config() == before
|
||||||
|
|
||||||
|
def test_save_allows_safe_env_var_change_in_existing_source(self):
|
||||||
|
config = self._start_with_placeholder_source()
|
||||||
|
config["environment_vars"]["FRIGATE_CAM_PATH"] = "video2"
|
||||||
|
resp = self._save(config)
|
||||||
|
assert resp.status_code == 200, resp.text
|
||||||
|
|
||||||
|
def test_save_resubmitting_placeholder_source_allowed(self):
|
||||||
|
config = self._start_with_placeholder_source()
|
||||||
|
resp = self._save(config)
|
||||||
|
assert resp.status_code == 200, resp.text
|
||||||
|
|
||||||
|
def test_save_rejects_removed_env_var_in_existing_source(self):
|
||||||
|
config = self._start_with_placeholder_source()
|
||||||
|
before = self._read_config()
|
||||||
|
del config["environment_vars"]
|
||||||
|
resp = self._save(config)
|
||||||
|
assert resp.status_code == 400
|
||||||
|
assert self._read_config() == before
|
||||||
|
|
||||||
|
def test_save_allows_env_var_added_with_its_source(self):
|
||||||
|
config = copy.deepcopy(_CONFIG)
|
||||||
|
config["environment_vars"] = {"FRIGATE_NEW_PATH": "video"}
|
||||||
|
config["go2rtc"]["streams"]["new_stream"] = (
|
||||||
|
"ffmpeg:rtsp://10.0.0.2:554/{FRIGATE_NEW_PATH}"
|
||||||
|
)
|
||||||
|
resp = self._save(config)
|
||||||
|
assert resp.status_code == 200, resp.text
|
||||||
|
|
||||||
|
def test_save_rejects_unsafe_env_var_added_with_its_source(self):
|
||||||
|
config = copy.deepcopy(_CONFIG)
|
||||||
|
config["environment_vars"] = {"FRIGATE_NEW_PATH": "video#raw=-vn"}
|
||||||
|
config["go2rtc"]["streams"]["new_stream"] = (
|
||||||
|
"ffmpeg:rtsp://10.0.0.2:554/{FRIGATE_NEW_PATH}"
|
||||||
|
)
|
||||||
|
resp = self._save(config)
|
||||||
|
assert resp.status_code == 400
|
||||||
|
|
||||||
# --- go2rtc ffmpeg and ngrok options ---
|
# --- go2rtc ffmpeg and ngrok options ---
|
||||||
|
|
||||||
def test_save_rejects_ffmpeg_bin_override(self):
|
def test_save_rejects_ffmpeg_bin_override(self):
|
||||||
|
|||||||
@@ -624,6 +624,96 @@ class TestConfigSetWildcardPropagation(BaseTestHttp):
|
|||||||
finally:
|
finally:
|
||||||
os.unlink(config_path)
|
os.unlink(config_path)
|
||||||
|
|
||||||
|
@patch.dict("frigate.util.env._CONFIG_ENV_VARS", {"FRIGATE_CAM_HOST": "10.0.0.1"})
|
||||||
|
@patch.dict("frigate.util.env.FRIGATE_ENV_VARS", {"FRIGATE_CAM_HOST": "10.0.0.1"})
|
||||||
|
@patch("frigate.api.app.find_config_file")
|
||||||
|
def test_masked_path_matches_after_saved_env_var_swap(self, mock_find_config):
|
||||||
|
"""A no-restart update swaps in a config resolved with the saved
|
||||||
|
environment_vars, so /config shows the saved value until a restart."""
|
||||||
|
path = "rtsp://admin:pw@{FRIGATE_CAM_HOST}:554/live"
|
||||||
|
self._set_inputs([(path, "detect")])
|
||||||
|
self.minimal_config["environment_vars"] = {"FRIGATE_CAM_HOST": "10.0.0.2"}
|
||||||
|
config_path = self._write_config_file()
|
||||||
|
mock_find_config.return_value = config_path
|
||||||
|
|
||||||
|
try:
|
||||||
|
app, _ = self._create_app_with_publisher()
|
||||||
|
|
||||||
|
with AuthTestClient(app) as client:
|
||||||
|
resp = self._save(
|
||||||
|
client, {"cameras": {"front_door": {"detect": {"fps": 6}}}}
|
||||||
|
)
|
||||||
|
self.assertEqual(resp.status_code, 200, resp.text)
|
||||||
|
|
||||||
|
camera = client.get("/config").json()["cameras"]["front_door"]
|
||||||
|
inputs = camera["ffmpeg"]["inputs"]
|
||||||
|
self.assertIn("10.0.0.2", inputs[0]["path"])
|
||||||
|
|
||||||
|
resp = self._save(
|
||||||
|
client,
|
||||||
|
{
|
||||||
|
"cameras": {
|
||||||
|
"front_door": {
|
||||||
|
"ffmpeg": {"inputs": inputs},
|
||||||
|
"detect": {"fps": 7},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
|
self.assertEqual(resp.status_code, 200, resp.text)
|
||||||
|
|
||||||
|
_, saved = self._read_config_file(config_path)
|
||||||
|
self.assertEqual(
|
||||||
|
saved["cameras"]["front_door"]["ffmpeg"]["inputs"][0]["path"], path
|
||||||
|
)
|
||||||
|
finally:
|
||||||
|
os.unlink(config_path)
|
||||||
|
|
||||||
|
@patch.dict(
|
||||||
|
"frigate.util.env._CONFIG_ENV_VARS",
|
||||||
|
{"FRIGATE_HOST_A": "10.0.0.1", "FRIGATE_HOST_B": "10.0.0.2"},
|
||||||
|
)
|
||||||
|
@patch.dict(
|
||||||
|
"frigate.util.env.FRIGATE_ENV_VARS",
|
||||||
|
{"FRIGATE_HOST_A": "10.0.0.1", "FRIGATE_HOST_B": "10.0.0.2"},
|
||||||
|
)
|
||||||
|
@patch("frigate.api.app.find_config_file")
|
||||||
|
def test_masked_paths_match_running_env_vars(self, mock_find_config):
|
||||||
|
"""A saved but not yet applied environment_vars change must not make
|
||||||
|
one input's masked path match another's."""
|
||||||
|
path_a = "rtsp://admin:pw@{FRIGATE_HOST_A}:554/live"
|
||||||
|
path_b = "rtsp://admin:pw@{FRIGATE_HOST_B}:554/live"
|
||||||
|
self._set_inputs([(path_a, "detect"), (path_b, "record")])
|
||||||
|
self.minimal_config["environment_vars"] = {
|
||||||
|
"FRIGATE_HOST_A": "10.0.0.1",
|
||||||
|
"FRIGATE_HOST_B": "10.0.0.2",
|
||||||
|
}
|
||||||
|
app, _ = self._create_app_with_publisher()
|
||||||
|
|
||||||
|
self.minimal_config["environment_vars"]["FRIGATE_HOST_A"] = "10.0.0.2"
|
||||||
|
config_path = self._write_config_file()
|
||||||
|
mock_find_config.return_value = config_path
|
||||||
|
|
||||||
|
try:
|
||||||
|
with AuthTestClient(app) as client:
|
||||||
|
camera = client.get("/config").json()["cameras"]["front_door"]
|
||||||
|
inputs = camera["ffmpeg"]["inputs"]
|
||||||
|
inputs[0]["roles"], inputs[1]["roles"] = ["record"], ["detect"]
|
||||||
|
|
||||||
|
resp = self._save(
|
||||||
|
client, {"cameras": {"front_door": {"ffmpeg": {"inputs": inputs}}}}
|
||||||
|
)
|
||||||
|
self.assertEqual(resp.status_code, 200, resp.text)
|
||||||
|
|
||||||
|
_, saved = self._read_config_file(config_path)
|
||||||
|
saved_inputs = saved["cameras"]["front_door"]["ffmpeg"]["inputs"]
|
||||||
|
self.assertEqual(
|
||||||
|
[(inp["path"], inp["roles"]) for inp in saved_inputs],
|
||||||
|
[(path_a, ["record"]), (path_b, ["detect"])],
|
||||||
|
)
|
||||||
|
finally:
|
||||||
|
os.unlink(config_path)
|
||||||
|
|
||||||
@patch("frigate.api.app.find_config_file")
|
@patch("frigate.api.app.find_config_file")
|
||||||
def test_over_masked_path_round_trips(self, mock_find_config):
|
def test_over_masked_path_round_trips(self, mock_find_config):
|
||||||
path = "rtsp://10.0.0.1:554/live?x=a@b"
|
path = "rtsp://10.0.0.1:554/live?x=a@b"
|
||||||
|
|||||||
@@ -374,6 +374,22 @@ class TestHttpApp(BaseTestHttp):
|
|||||||
event_after_delete = client.get(f"/events/{id}")
|
event_after_delete = client.get(f"/events/{id}")
|
||||||
assert event_after_delete.status_code == 404
|
assert event_after_delete.status_code == 404
|
||||||
|
|
||||||
|
def test_event_retention(self):
|
||||||
|
id = "123456.random"
|
||||||
|
|
||||||
|
with AuthTestClient(self.app) as client:
|
||||||
|
super().insert_mock_event(id)
|
||||||
|
client.post(f"/events/{id}/retain", headers={"remote-role": "admin"})
|
||||||
|
event = client.get(f"/events/{id}").json()
|
||||||
|
assert event
|
||||||
|
assert event["id"] == id
|
||||||
|
assert event["retain_indefinitely"] is True
|
||||||
|
client.delete(f"/events/{id}/retain", headers={"remote-role": "admin"})
|
||||||
|
event = client.get(f"/events/{id}").json()
|
||||||
|
assert event
|
||||||
|
assert event["id"] == id
|
||||||
|
assert event["retain_indefinitely"] is False
|
||||||
|
|
||||||
def test_event_time_filtering(self):
|
def test_event_time_filtering(self):
|
||||||
morning_id = "123456.random"
|
morning_id = "123456.random"
|
||||||
evening_id = "654321.random"
|
evening_id = "654321.random"
|
||||||
@@ -511,32 +527,42 @@ class TestHttpApp(BaseTestHttp):
|
|||||||
with AuthTestClient(self.app) as client:
|
with AuthTestClient(self.app) as client:
|
||||||
ts_start = datetime.now().timestamp()
|
ts_start = datetime.now().timestamp()
|
||||||
ts_end = ts_start + 30
|
ts_end = ts_start + 30
|
||||||
_insert_mock_event(id="abcde.random", start=ts_start, end=ts_end)
|
_insert_mock_event(
|
||||||
_insert_mock_event(id="01234.random", start=ts_start, end=ts_end)
|
id="abcde.random", start=ts_start, end=ts_end, retain=True
|
||||||
_insert_mock_event(id="56789.random", start=ts_start, end=ts_end)
|
)
|
||||||
|
_insert_mock_event(
|
||||||
|
id="01234.random", start=ts_start, end=ts_end, retain=True
|
||||||
|
)
|
||||||
|
_insert_mock_event(
|
||||||
|
id="56789.random", start=ts_start, end=ts_end, retain=True
|
||||||
|
)
|
||||||
_insert_mock_event(
|
_insert_mock_event(
|
||||||
id="101112.random",
|
id="101112.random",
|
||||||
label="outside",
|
label="outside",
|
||||||
start=ts_start,
|
start=ts_start,
|
||||||
end=ts_end,
|
end=ts_end,
|
||||||
|
retain=True,
|
||||||
)
|
)
|
||||||
_insert_mock_event(
|
_insert_mock_event(
|
||||||
id="131415.random",
|
id="131415.random",
|
||||||
label="outside",
|
label="outside",
|
||||||
start=ts_start,
|
start=ts_start,
|
||||||
end=ts_end,
|
end=ts_end,
|
||||||
|
retain=True,
|
||||||
)
|
)
|
||||||
_insert_mock_event(
|
_insert_mock_event(
|
||||||
id="161718.random",
|
id="161718.random",
|
||||||
camera="porch",
|
camera="porch",
|
||||||
start=ts_start,
|
start=ts_start,
|
||||||
end=ts_end,
|
end=ts_end,
|
||||||
|
retain=True,
|
||||||
)
|
)
|
||||||
_insert_mock_event(
|
_insert_mock_event(
|
||||||
id="192021.random",
|
id="192021.random",
|
||||||
camera="porch",
|
camera="porch",
|
||||||
start=ts_start,
|
start=ts_start,
|
||||||
end=ts_end,
|
end=ts_end,
|
||||||
|
retain=True,
|
||||||
)
|
)
|
||||||
_insert_mock_event(
|
_insert_mock_event(
|
||||||
id="222324.random",
|
id="222324.random",
|
||||||
@@ -544,6 +570,7 @@ class TestHttpApp(BaseTestHttp):
|
|||||||
label="inside",
|
label="inside",
|
||||||
start=ts_start,
|
start=ts_start,
|
||||||
end=ts_end,
|
end=ts_end,
|
||||||
|
retain=True,
|
||||||
)
|
)
|
||||||
_insert_mock_event(
|
_insert_mock_event(
|
||||||
id="252627.random",
|
id="252627.random",
|
||||||
@@ -551,18 +578,21 @@ class TestHttpApp(BaseTestHttp):
|
|||||||
label="inside",
|
label="inside",
|
||||||
start=ts_start,
|
start=ts_start,
|
||||||
end=ts_end,
|
end=ts_end,
|
||||||
|
retain=True,
|
||||||
)
|
)
|
||||||
_insert_mock_event(
|
_insert_mock_event(
|
||||||
id="282930.random",
|
id="282930.random",
|
||||||
label="inside",
|
label="inside",
|
||||||
start=ts_start,
|
start=ts_start,
|
||||||
end=ts_end,
|
end=ts_end,
|
||||||
|
retain=True,
|
||||||
)
|
)
|
||||||
_insert_mock_event(
|
_insert_mock_event(
|
||||||
id="313233.random",
|
id="313233.random",
|
||||||
label="inside",
|
label="inside",
|
||||||
start=ts_start,
|
start=ts_start,
|
||||||
end=ts_end,
|
end=ts_end,
|
||||||
|
retain=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
stats_emitter = Mock(spec=StatsEmitter)
|
stats_emitter = Mock(spec=StatsEmitter)
|
||||||
|
|||||||
@@ -122,6 +122,7 @@ class TestExecuteFindSimilarObjects(unittest.TestCase):
|
|||||||
region=[0, 0, 1, 1],
|
region=[0, 0, 1, 1],
|
||||||
box=[0, 0, 1, 1],
|
box=[0, 0, 1, 1],
|
||||||
area=1,
|
area=1,
|
||||||
|
retain_indefinitely=False,
|
||||||
ratio=1.0,
|
ratio=1.0,
|
||||||
plus_id="",
|
plus_id="",
|
||||||
model_hash="",
|
model_hash="",
|
||||||
|
|||||||
@@ -259,6 +259,7 @@ class DatabaseTestCase(unittest.TestCase):
|
|||||||
region=[0, 0, 1, 1],
|
region=[0, 0, 1, 1],
|
||||||
box=[0, 0, 1, 1],
|
box=[0, 0, 1, 1],
|
||||||
area=1,
|
area=1,
|
||||||
|
retain_indefinitely=False,
|
||||||
ratio=1.0,
|
ratio=1.0,
|
||||||
plus_id="",
|
plus_id="",
|
||||||
model_hash="",
|
model_hash="",
|
||||||
|
|||||||
@@ -518,11 +518,47 @@ class TestSecretsReload(unittest.TestCase):
|
|||||||
"""
|
"""
|
||||||
env.apply_config_env_vars({"FRIGATE_MQTT_HOST": "from_config"})
|
env.apply_config_env_vars({"FRIGATE_MQTT_HOST": "from_config"})
|
||||||
config = FrigateConfig.parse_yaml(
|
config = FrigateConfig.parse_yaml(
|
||||||
|
"environment_vars:\n FRIGATE_MQTT_HOST: from_config\n"
|
||||||
'mqtt:\n host: "{FRIGATE_MQTT_HOST}"\ncameras: {}\n'
|
'mqtt:\n host: "{FRIGATE_MQTT_HOST}"\ncameras: {}\n'
|
||||||
)
|
)
|
||||||
self.assertEqual(config.mqtt.host, "from_config")
|
self.assertEqual(config.mqtt.host, "from_config")
|
||||||
self.assertEqual(env._CONFIG_ENV_VARS["FRIGATE_MQTT_HOST"], "from_config")
|
self.assertEqual(env._CONFIG_ENV_VARS["FRIGATE_MQTT_HOST"], "from_config")
|
||||||
|
|
||||||
|
def test_candidate_env_var_resolves_before_install(self):
|
||||||
|
"""A non-install parse resolves against the candidate's own block, so
|
||||||
|
an entry can be added and referenced in the same save."""
|
||||||
|
env.apply_config_env_vars({"FRIGATE_MQTT_HOST": "running"})
|
||||||
|
config = FrigateConfig.parse_yaml(
|
||||||
|
"environment_vars:\n FRIGATE_MQTT_HOST: candidate\n"
|
||||||
|
" FRIGATE_MQTT_USER: added\n"
|
||||||
|
'mqtt:\n host: "{FRIGATE_MQTT_HOST}"\n'
|
||||||
|
' user: "{FRIGATE_MQTT_USER}"\n password: secret\ncameras: {}\n'
|
||||||
|
)
|
||||||
|
self.assertEqual(config.mqtt.host, "candidate")
|
||||||
|
self.assertEqual(config.mqtt.user, "added")
|
||||||
|
self.assertEqual(env._CONFIG_ENV_VARS, {"FRIGATE_MQTT_HOST": "running"})
|
||||||
|
self.assertNotIn("FRIGATE_MQTT_USER", os.environ)
|
||||||
|
|
||||||
|
def test_removed_candidate_env_var_fails_validation(self):
|
||||||
|
"""Removing an entry that is still referenced fails now, not at the
|
||||||
|
next start."""
|
||||||
|
env.apply_config_env_vars({"FRIGATE_MQTT_HOST": "running"})
|
||||||
|
with self.assertRaises(ValidationError):
|
||||||
|
FrigateConfig.parse_yaml(
|
||||||
|
'mqtt:\n host: "{FRIGATE_MQTT_HOST}"\ncameras: {}\n'
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_candidate_env_var_keeps_lowest_precedence(self):
|
||||||
|
"""secrets.yaml still outranks the candidate's block."""
|
||||||
|
with open(os.path.join(self._dir.name, "secrets.yaml"), "w") as f:
|
||||||
|
f.write("FRIGATE_MQTT_HOST: from_secrets\n")
|
||||||
|
|
||||||
|
config = FrigateConfig.parse_yaml(
|
||||||
|
"environment_vars:\n FRIGATE_MQTT_HOST: candidate\n"
|
||||||
|
'mqtt:\n host: "{FRIGATE_MQTT_HOST}"\ncameras: {}\n'
|
||||||
|
)
|
||||||
|
self.assertEqual(config.mqtt.host, "from_secrets")
|
||||||
|
|
||||||
|
|
||||||
class TestSourceRobustness(unittest.TestCase):
|
class TestSourceRobustness(unittest.TestCase):
|
||||||
"""Reload behavior, bad input, and the os.environ export."""
|
"""Reload behavior, bad input, and the os.environ export."""
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ class TestEventCleanup(unittest.TestCase):
|
|||||||
region=[],
|
region=[],
|
||||||
box=[],
|
box=[],
|
||||||
area=0,
|
area=0,
|
||||||
|
retain_indefinitely=False,
|
||||||
plus_id="",
|
plus_id="",
|
||||||
model_hash="",
|
model_hash="",
|
||||||
detector_type="cpu",
|
detector_type="cpu",
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ class TestEventCleanupSnapshots(unittest.TestCase):
|
|||||||
region=[],
|
region=[],
|
||||||
box=[],
|
box=[],
|
||||||
area=0,
|
area=0,
|
||||||
|
retain_indefinitely=False,
|
||||||
plus_id="",
|
plus_id="",
|
||||||
model_hash="",
|
model_hash="",
|
||||||
detector_type="cpu",
|
detector_type="cpu",
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ class TestEventCleanupSubRetention(unittest.TestCase):
|
|||||||
region=[],
|
region=[],
|
||||||
box=[],
|
box=[],
|
||||||
area=0,
|
area=0,
|
||||||
|
retain_indefinitely=False,
|
||||||
plus_id="",
|
plus_id="",
|
||||||
model_hash="",
|
model_hash="",
|
||||||
detector_type="cpu",
|
detector_type="cpu",
|
||||||
|
|||||||
@@ -122,11 +122,6 @@ class TestResolveMediaUri(unittest.TestCase):
|
|||||||
MediaAuthResolution.CAMERA,
|
MediaAuthResolution.CAMERA,
|
||||||
camera="back_door",
|
camera="back_door",
|
||||||
)
|
)
|
||||||
self._assert(
|
|
||||||
"/recordings/2026-05-11/14/back_door@sub/00.00.mp4",
|
|
||||||
MediaAuthResolution.CAMERA,
|
|
||||||
camera="back_door",
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_clip_flat_filename_resolves_camera(self):
|
def test_clip_flat_filename_resolves_camera(self):
|
||||||
self._assert(
|
self._assert(
|
||||||
@@ -182,14 +177,6 @@ class TestResolveMediaUri(unittest.TestCase):
|
|||||||
camera="back_door",
|
camera="back_door",
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_clip_triggers(self):
|
|
||||||
self._assert("/clips/triggers/", MediaAuthResolution.LISTING_MULTI_CAMERA)
|
|
||||||
self._assert(
|
|
||||||
"/clips/triggers/back_door/abc.webp",
|
|
||||||
MediaAuthResolution.CAMERA,
|
|
||||||
camera="back_door",
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_clip_review_thumbs(self):
|
def test_clip_review_thumbs(self):
|
||||||
# Format: /clips/review/thumb-{camera}-{review_id}.webp (frigate/review/maintainer.py).
|
# Format: /clips/review/thumb-{camera}-{review_id}.webp (frigate/review/maintainer.py).
|
||||||
self._assert(
|
self._assert(
|
||||||
@@ -353,14 +340,6 @@ class TestDenyResponseForMediaUri(unittest.TestCase):
|
|||||||
self.assertIsNone(
|
self.assertIsNone(
|
||||||
self._deny("/clips/thumbs/front_door/abc.webp", "limited_user")
|
self._deny("/clips/thumbs/front_door/abc.webp", "limited_user")
|
||||||
)
|
)
|
||||||
self.assertIsNone(
|
|
||||||
self._deny(
|
|
||||||
"/recordings/2026-05-11/14/front_door@sub/00.00.mp4", "limited_user"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
self.assertIsNone(
|
|
||||||
self._deny("/clips/triggers/front_door/abc.webp", "limited_user")
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_restricted_role_blocked_other_camera(self):
|
def test_restricted_role_blocked_other_camera(self):
|
||||||
self.assertEqual(self._deny("/clips/back_door-1.jpg", "limited_user"), 403)
|
self.assertEqual(self._deny("/clips/back_door-1.jpg", "limited_user"), 403)
|
||||||
@@ -371,15 +350,6 @@ class TestDenyResponseForMediaUri(unittest.TestCase):
|
|||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self._deny("/clips/thumbs/back_door/abc.webp", "limited_user"), 403
|
self._deny("/clips/thumbs/back_door/abc.webp", "limited_user"), 403
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
|
||||||
self._deny(
|
|
||||||
"/recordings/2026-05-11/14/back_door@sub/00.00.mp4", "limited_user"
|
|
||||||
),
|
|
||||||
403,
|
|
||||||
)
|
|
||||||
self.assertEqual(
|
|
||||||
self._deny("/clips/triggers/back_door/abc.webp", "limited_user"), 403
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_restricted_role_blocked_admin_only(self):
|
def test_restricted_role_blocked_admin_only(self):
|
||||||
self.assertEqual(self._deny("/clips/faces/train/foo.webp", "limited_user"), 403)
|
self.assertEqual(self._deny("/clips/faces/train/foo.webp", "limited_user"), 403)
|
||||||
|
|||||||
@@ -1,65 +0,0 @@
|
|||||||
"""Tests for media sync orphan cleanup."""
|
|
||||||
|
|
||||||
import os
|
|
||||||
import tempfile
|
|
||||||
import unittest
|
|
||||||
from unittest.mock import patch
|
|
||||||
|
|
||||||
from peewee import SqliteDatabase
|
|
||||||
|
|
||||||
from frigate.models import Export, ExportCase
|
|
||||||
from frigate.util.media import sync_exports
|
|
||||||
|
|
||||||
|
|
||||||
class TestSyncExports(unittest.TestCase):
|
|
||||||
def setUp(self):
|
|
||||||
self.db = SqliteDatabase(":memory:")
|
|
||||||
self.enterContext(self.db.bind_ctx([Export, ExportCase]))
|
|
||||||
self.db.create_tables([Export, ExportCase])
|
|
||||||
|
|
||||||
self.tmp = tempfile.TemporaryDirectory()
|
|
||||||
self.clips_dir = os.path.join(self.tmp.name, "clips")
|
|
||||||
self.export_dir = os.path.join(self.tmp.name, "exports")
|
|
||||||
self.thumb_dir = os.path.join(self.clips_dir, "export")
|
|
||||||
os.makedirs(self.thumb_dir)
|
|
||||||
os.makedirs(self.export_dir)
|
|
||||||
|
|
||||||
patcher_clips = patch("frigate.util.media.CLIPS_DIR", self.clips_dir)
|
|
||||||
patcher_exports = patch("frigate.util.media.EXPORT_DIR", self.export_dir)
|
|
||||||
patcher_clips.start()
|
|
||||||
patcher_exports.start()
|
|
||||||
self.addCleanup(patcher_clips.stop)
|
|
||||||
self.addCleanup(patcher_exports.stop)
|
|
||||||
|
|
||||||
def tearDown(self):
|
|
||||||
self.db.close()
|
|
||||||
self.tmp.cleanup()
|
|
||||||
|
|
||||||
def _touch(self, path: str) -> str:
|
|
||||||
open(path, "wb").close()
|
|
||||||
return path
|
|
||||||
|
|
||||||
def test_orphaned_webp_and_jpg_thumbnails_are_removed(self):
|
|
||||||
for i, ext in enumerate(("webp", "jpg")):
|
|
||||||
Export.insert(
|
|
||||||
id=f"front_{i}",
|
|
||||||
camera="front",
|
|
||||||
name=f"export {i}",
|
|
||||||
date=0,
|
|
||||||
video_path=self._touch(os.path.join(self.export_dir, f"{i}.mp4")),
|
|
||||||
thumb_path=self._touch(os.path.join(self.thumb_dir, f"{i}.{ext}")),
|
|
||||||
in_progress=False,
|
|
||||||
).execute()
|
|
||||||
|
|
||||||
orphan_webp = self._touch(os.path.join(self.thumb_dir, "gone.webp"))
|
|
||||||
orphan_jpg = self._touch(os.path.join(self.thumb_dir, "gone.jpg"))
|
|
||||||
|
|
||||||
result = sync_exports()
|
|
||||||
|
|
||||||
self.assertEqual(sorted(result.orphan_paths), sorted([orphan_jpg, orphan_webp]))
|
|
||||||
self.assertEqual(result.orphans_deleted, 2)
|
|
||||||
self.assertEqual(sorted(os.listdir(self.thumb_dir)), ["0.webp", "1.jpg"])
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
unittest.main()
|
|
||||||
@@ -98,6 +98,7 @@ class TestRegeneratedSubLabels(unittest.TestCase):
|
|||||||
region=[],
|
region=[],
|
||||||
box=[],
|
box=[],
|
||||||
area=0,
|
area=0,
|
||||||
|
retain_indefinitely=False,
|
||||||
plus_id="",
|
plus_id="",
|
||||||
model_hash="",
|
model_hash="",
|
||||||
detector_type="cpu",
|
detector_type="cpu",
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import datetime
|
import datetime
|
||||||
import gc
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import tempfile
|
import tempfile
|
||||||
@@ -478,7 +477,12 @@ class TestHttp(unittest.TestCase):
|
|||||||
|
|
||||||
id = "123456.keep"
|
id = "123456.keep"
|
||||||
time_keep = datetime.datetime.now().timestamp()
|
time_keep = datetime.datetime.now().timestamp()
|
||||||
_insert_mock_event(id, time_keep, time_keep + 30)
|
_insert_mock_event(
|
||||||
|
id,
|
||||||
|
time_keep,
|
||||||
|
time_keep + 30,
|
||||||
|
True,
|
||||||
|
)
|
||||||
rec_k_id = "1234567.keep"
|
rec_k_id = "1234567.keep"
|
||||||
rec_k2_id = "1234568.keep"
|
rec_k2_id = "1234568.keep"
|
||||||
rec_k3_id = "1234569.keep"
|
rec_k3_id = "1234569.keep"
|
||||||
@@ -503,7 +507,7 @@ class TestHttp(unittest.TestCase):
|
|||||||
|
|
||||||
id2 = "7890.delete"
|
id2 = "7890.delete"
|
||||||
time_delete = datetime.datetime.now().timestamp() - 360
|
time_delete = datetime.datetime.now().timestamp() - 360
|
||||||
_insert_mock_event(id2, time_delete, time_delete + 30)
|
_insert_mock_event(id2, time_delete, time_delete + 30, False)
|
||||||
rec_d_id = "78901.delete"
|
rec_d_id = "78901.delete"
|
||||||
rec_d2_id = "78902.delete"
|
rec_d2_id = "78902.delete"
|
||||||
rec_d3_id = "78903.delete"
|
rec_d3_id = "78903.delete"
|
||||||
@@ -536,15 +540,14 @@ class TestHttp(unittest.TestCase):
|
|||||||
Recordings.get(Recordings.id == rec_d2_id)
|
Recordings.get(Recordings.id == rec_d2_id)
|
||||||
Recordings.get(Recordings.id == rec_d3_id)
|
Recordings.get(Recordings.id == rec_d3_id)
|
||||||
|
|
||||||
def test_storage_cleanup_deletes_oldest_first(self):
|
def test_storage_cleanup_keeps_retained(self):
|
||||||
"""Ensure cleanup deletes the oldest segments and only expires their events."""
|
"""Ensure cleanup steps over retained segments to reach newer ones."""
|
||||||
config = FrigateConfig(**self.minimal_config)
|
config = FrigateConfig(**self.minimal_config)
|
||||||
storage = StorageMaintainer(config, MagicMock())
|
storage = StorageMaintainer(config, MagicMock())
|
||||||
|
|
||||||
seg_len = 600
|
seg_len = 600
|
||||||
base = datetime.datetime.now().timestamp() - 7200
|
base = datetime.datetime.now().timestamp() - 7200
|
||||||
_insert_mock_event("old.event", base, base + 2.5 * seg_len)
|
_insert_mock_event("123456.keep", base, base + 2.5 * seg_len, True)
|
||||||
_insert_mock_event("new.event", base + 8 * seg_len, base + 9.5 * seg_len)
|
|
||||||
|
|
||||||
paths = {}
|
paths = {}
|
||||||
for i in range(10):
|
for i in range(10):
|
||||||
@@ -554,23 +557,16 @@ class TestHttp(unittest.TestCase):
|
|||||||
rec_id, paths[rec_id], base + i * seg_len, base + (i + 1) * seg_len
|
rec_id, paths[rec_id], base + i * seg_len, base + (i + 1) * seg_len
|
||||||
)
|
)
|
||||||
|
|
||||||
# Hourly bandwidth is 48 MB, so cleanup removes the oldest 56 MB
|
# Hourly bandwidth is 48 MB, so cleanup needs all 56 MB of unretained
|
||||||
|
# segments and must pass the older retained ones to get there.
|
||||||
storage.calculate_camera_bandwidth()
|
storage.calculate_camera_bandwidth()
|
||||||
storage.reduce_storage_consumption()
|
storage.reduce_storage_consumption()
|
||||||
|
|
||||||
# flush the queued writes, and collect the abandoned recordings
|
retained = {"segment-0", "segment-1", "segment-2"}
|
||||||
# cursor so this connection stops reading its stale snapshot
|
|
||||||
self.db.stop()
|
|
||||||
self.db.start()
|
|
||||||
gc.collect()
|
|
||||||
|
|
||||||
kept = {"segment-7", "segment-8", "segment-9"}
|
|
||||||
remaining = {r.id for r in Recordings.select(Recordings.id)}
|
remaining = {r.id for r in Recordings.select(Recordings.id)}
|
||||||
on_disk = {rec_id for rec_id, path in paths.items() if os.path.exists(path)}
|
on_disk = {rec_id for rec_id, path in paths.items() if os.path.exists(path)}
|
||||||
self.assertEqual(remaining, kept)
|
self.assertEqual(remaining, retained)
|
||||||
self.assertEqual(on_disk, kept)
|
self.assertEqual(on_disk, retained)
|
||||||
self.assertFalse(Event.get(Event.id == "old.event").has_clip)
|
|
||||||
self.assertTrue(Event.get(Event.id == "new.event").has_clip)
|
|
||||||
self.assertFalse(storage.retention_unmet)
|
self.assertFalse(storage.retention_unmet)
|
||||||
|
|
||||||
def test_unmet_retention_sets_the_live_flag(self):
|
def test_unmet_retention_sets_the_live_flag(self):
|
||||||
@@ -600,6 +596,7 @@ def _insert_mock_event(
|
|||||||
id: str,
|
id: str,
|
||||||
start: int,
|
start: int,
|
||||||
end: int,
|
end: int,
|
||||||
|
retain: bool,
|
||||||
camera: str = "front_door",
|
camera: str = "front_door",
|
||||||
label: str = "Mock",
|
label: str = "Mock",
|
||||||
) -> Event:
|
) -> Event:
|
||||||
@@ -619,6 +616,7 @@ def _insert_mock_event(
|
|||||||
area=0,
|
area=0,
|
||||||
has_clip=True,
|
has_clip=True,
|
||||||
has_snapshot=True,
|
has_snapshot=True,
|
||||||
|
retain_indefinitely=retain,
|
||||||
).execute()
|
).execute()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,42 +0,0 @@
|
|||||||
"""Tests for trigger push notifications."""
|
|
||||||
|
|
||||||
import unittest
|
|
||||||
from types import SimpleNamespace
|
|
||||||
from unittest.mock import MagicMock
|
|
||||||
|
|
||||||
from frigate.comms.webpush import WebPushClient
|
|
||||||
|
|
||||||
|
|
||||||
class TestTriggerNotification(unittest.TestCase):
|
|
||||||
def test_image_is_the_triggering_event_thumbnail(self):
|
|
||||||
client = WebPushClient.__new__(WebPushClient)
|
|
||||||
client.config = SimpleNamespace(
|
|
||||||
notifications=SimpleNamespace(email="admin@example.com"),
|
|
||||||
cameras={"front_door": SimpleNamespace(friendly_name=None)},
|
|
||||||
)
|
|
||||||
client.web_pushers = {"admin": []}
|
|
||||||
client.user_cameras = {"admin": {"front_door"}}
|
|
||||||
client.last_camera_notification_time = {}
|
|
||||||
client._within_cooldown = MagicMock(return_value=False)
|
|
||||||
client.check_registrations = MagicMock()
|
|
||||||
client.cleanup_registrations = MagicMock()
|
|
||||||
client.send_push_notification = MagicMock()
|
|
||||||
|
|
||||||
client.send_trigger(
|
|
||||||
{
|
|
||||||
"camera": "front_door",
|
|
||||||
"event_id": "1700000000.0-abc123",
|
|
||||||
"name": "red_car",
|
|
||||||
"type": "thumbnail",
|
|
||||||
"score": 0.9,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
self.assertEqual(
|
|
||||||
client.send_push_notification.call_args.kwargs["image"],
|
|
||||||
"api/events/1700000000.0-abc123/thumbnail.webp",
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
unittest.main()
|
|
||||||
+40
-4
@@ -3,7 +3,9 @@
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
from collections.abc import Mapping
|
from collections.abc import Iterator, Mapping
|
||||||
|
from contextlib import contextmanager
|
||||||
|
from contextvars import ContextVar
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Annotated, Any
|
from typing import Annotated, Any
|
||||||
|
|
||||||
@@ -246,6 +248,35 @@ def apply_config_env_vars(values: Mapping[str, object]) -> None:
|
|||||||
reload_sources(warn=False)
|
reload_sources(warn=False)
|
||||||
|
|
||||||
|
|
||||||
|
_CANDIDATE_ENV_VARS: ContextVar[dict[str, str] | None] = ContextVar(
|
||||||
|
"candidate_env_vars", default=None
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@contextmanager
|
||||||
|
def candidate_env_vars(values: object) -> Iterator[None]:
|
||||||
|
"""Resolve placeholders against a candidate config's environment_vars.
|
||||||
|
|
||||||
|
Its FRIGATE_ keys replace the installed block at the same lowest
|
||||||
|
precedence. Nothing is installed or exported to os.environ.
|
||||||
|
"""
|
||||||
|
merged = {
|
||||||
|
str(key): str(value)
|
||||||
|
for key, value in (values.items() if isinstance(values, Mapping) else ())
|
||||||
|
if str(key).startswith("FRIGATE_")
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, source in _SOURCES:
|
||||||
|
if source is not _CONFIG_ENV_VARS:
|
||||||
|
merged.update(source)
|
||||||
|
|
||||||
|
token = _CANDIDATE_ENV_VARS.set(merged)
|
||||||
|
try:
|
||||||
|
yield
|
||||||
|
finally:
|
||||||
|
_CANDIDATE_ENV_VARS.reset(token)
|
||||||
|
|
||||||
|
|
||||||
# Matches a FRIGATE_* identifier following an opening brace.
|
# Matches a FRIGATE_* identifier following an opening brace.
|
||||||
_FRIGATE_IDENT_RE = re.compile(r"FRIGATE_[A-Za-z0-9_]+")
|
_FRIGATE_IDENT_RE = re.compile(r"FRIGATE_[A-Za-z0-9_]+")
|
||||||
|
|
||||||
@@ -258,7 +289,8 @@ def substitute_frigate_vars(value: str) -> str:
|
|||||||
(e.g. ffmpeg `%{localtime\\:...}` expressions) untouched:
|
(e.g. ffmpeg `%{localtime\\:...}` expressions) untouched:
|
||||||
|
|
||||||
* `{{` and `}}` collapse to literal `{` / `}` (the documented escape).
|
* `{{` and `}}` collapse to literal `{` / `}` (the documented escape).
|
||||||
* `{FRIGATE_NAME}` is replaced from `FRIGATE_ENV_VARS`; an unknown name
|
* `{FRIGATE_NAME}` is replaced from `FRIGATE_ENV_VARS`, or from the
|
||||||
|
sources set by `candidate_env_vars`; an unknown name
|
||||||
raises `UnknownVariableError` to preserve the existing "Invalid
|
raises `UnknownVariableError` to preserve the existing "Invalid
|
||||||
substitution" error path.
|
substitution" error path.
|
||||||
* A `{` that begins `{FRIGATE_` but is not a well-formed
|
* A `{` that begins `{FRIGATE_` but is not a well-formed
|
||||||
@@ -268,6 +300,10 @@ def substitute_frigate_vars(value: str) -> str:
|
|||||||
error.
|
error.
|
||||||
* Any other `{` or `}` is treated as a literal and passed through.
|
* Any other `{` or `}` is treated as a literal and passed through.
|
||||||
"""
|
"""
|
||||||
|
env_vars = _CANDIDATE_ENV_VARS.get()
|
||||||
|
if env_vars is None:
|
||||||
|
env_vars = FRIGATE_ENV_VARS
|
||||||
|
|
||||||
out: list[str] = []
|
out: list[str] = []
|
||||||
i = 0
|
i = 0
|
||||||
n = len(value)
|
n = len(value)
|
||||||
@@ -288,12 +324,12 @@ def substitute_frigate_vars(value: str) -> str:
|
|||||||
and value[ident_match.end()] == "}"
|
and value[ident_match.end()] == "}"
|
||||||
):
|
):
|
||||||
key = ident_match.group(0)
|
key = ident_match.group(0)
|
||||||
if key not in FRIGATE_ENV_VARS:
|
if key not in env_vars:
|
||||||
raise UnknownVariableError(
|
raise UnknownVariableError(
|
||||||
f"{key} is not defined in the environment, "
|
f"{key} is not defined in the environment, "
|
||||||
"secrets.yaml, or the environment_vars config"
|
"secrets.yaml, or the environment_vars config"
|
||||||
)
|
)
|
||||||
out.append(FRIGATE_ENV_VARS[key])
|
out.append(env_vars[key])
|
||||||
i = ident_match.end() + 1
|
i = ident_match.end() + 1
|
||||||
continue
|
continue
|
||||||
# Looks like a FRIGATE placeholder but is malformed
|
# Looks like a FRIGATE placeholder but is malformed
|
||||||
|
|||||||
@@ -639,7 +639,7 @@ def sync_exports(dry_run: bool = False, force: bool = False) -> SyncResult:
|
|||||||
"""Sync export files - delete files not referenced by any export record.
|
"""Sync export files - delete files not referenced by any export record.
|
||||||
|
|
||||||
Export videos are stored at: EXPORT_DIR/*.mp4
|
Export videos are stored at: EXPORT_DIR/*.mp4
|
||||||
Export thumbnails are stored at: CLIPS_DIR/export/*.webp (legacy *.jpg)
|
Export thumbnails are stored at: CLIPS_DIR/export/*.jpg
|
||||||
The paths are stored in Export.video_path and Export.thumb_path
|
The paths are stored in Export.video_path and Export.thumb_path
|
||||||
"""
|
"""
|
||||||
result = SyncResult(media_type="exports")
|
result = SyncResult(media_type="exports")
|
||||||
@@ -667,7 +667,7 @@ def sync_exports(dry_run: bool = False, force: bool = False) -> SyncResult:
|
|||||||
thumb_files: list[str] = []
|
thumb_files: list[str] = []
|
||||||
if os.path.isdir(export_thumb_dir):
|
if os.path.isdir(export_thumb_dir):
|
||||||
for file in os.listdir(export_thumb_dir):
|
for file in os.listdir(export_thumb_dir):
|
||||||
if file.endswith((".webp", ".jpg")):
|
if file.endswith(".jpg"):
|
||||||
file_path = os.path.join(export_thumb_dir, file)
|
file_path = os.path.join(export_thumb_dir, file)
|
||||||
thumb_files.append(file_path)
|
thumb_files.append(file_path)
|
||||||
|
|
||||||
|
|||||||
+30
-13
@@ -30,7 +30,11 @@ from frigate.const import (
|
|||||||
SHM_FRAMES_VAR,
|
SHM_FRAMES_VAR,
|
||||||
)
|
)
|
||||||
from frigate.util.builtin import clean_camera_user_pass, escape_special_characters
|
from frigate.util.builtin import clean_camera_user_pass, escape_special_characters
|
||||||
from frigate.util.env import UnknownVariableError, substitute_frigate_vars
|
from frigate.util.env import (
|
||||||
|
UnknownVariableError,
|
||||||
|
candidate_env_vars,
|
||||||
|
substitute_frigate_vars,
|
||||||
|
)
|
||||||
from frigate.util.live_streams import is_valid_go2rtc_stream_name
|
from frigate.util.live_streams import is_valid_go2rtc_stream_name
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@@ -1228,16 +1232,27 @@ class Go2rtcStreamIssue(str, Enum):
|
|||||||
invalid_name = "invalid_name"
|
invalid_name = "invalid_name"
|
||||||
|
|
||||||
|
|
||||||
|
def _resolve_running_frigate_vars(source: str) -> str | None:
|
||||||
|
try:
|
||||||
|
return substitute_frigate_vars(source)
|
||||||
|
except ValueError:
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
def find_restricted_go2rtc_stream_changes(
|
def find_restricted_go2rtc_stream_changes(
|
||||||
old_streams: dict[str, Any] | None, new_streams: dict[str, Any] | None
|
old_streams: dict[str, Any] | None,
|
||||||
|
new_streams: dict[str, Any] | None,
|
||||||
|
new_env_vars: object,
|
||||||
) -> dict[str, Go2rtcStreamIssue]:
|
) -> dict[str, Go2rtcStreamIssue]:
|
||||||
"""Return the go2rtc streams with new sources that must be rejected.
|
"""Return the go2rtc streams with new sources that must be rejected.
|
||||||
|
|
||||||
Used when the config is changed through the API. A source that is already
|
Used when the config is changed through the API. Every source must resolve
|
||||||
in the saved config for the same stream is left alone, so streams the
|
its {FRIGATE_*} placeholders against the new config's environment_vars. A
|
||||||
operator configured on disk keep working; any other source must resolve
|
source that is already in the saved config for the same stream and
|
||||||
its {FRIGATE_*} placeholders and pass `is_restricted_go2rtc_api_source`.
|
resolves to the same value as it does now is left alone, so streams the
|
||||||
New stream names must pass `is_valid_go2rtc_stream_name`.
|
operator configured on disk keep working; any other source must pass
|
||||||
|
`is_restricted_go2rtc_api_source`. New stream names must pass
|
||||||
|
`is_valid_go2rtc_stream_name`.
|
||||||
"""
|
"""
|
||||||
old_streams = old_streams if isinstance(old_streams, dict) else {}
|
old_streams = old_streams if isinstance(old_streams, dict) else {}
|
||||||
new_streams = new_streams if isinstance(new_streams, dict) else {}
|
new_streams = new_streams if isinstance(new_streams, dict) else {}
|
||||||
@@ -1251,19 +1266,16 @@ def find_restricted_go2rtc_stream_changes(
|
|||||||
existing = _go2rtc_stream_sources(old_streams.get(name))
|
existing = _go2rtc_stream_sources(old_streams.get(name))
|
||||||
|
|
||||||
for source in _go2rtc_stream_sources(stream):
|
for source in _go2rtc_stream_sources(stream):
|
||||||
if source in existing:
|
|
||||||
continue
|
|
||||||
|
|
||||||
if not isinstance(source, str):
|
if not isinstance(source, str):
|
||||||
# the map form is only usable with arbitrary exec enabled
|
# the map form is only usable with arbitrary exec enabled
|
||||||
if is_go2rtc_arbitrary_exec_allowed():
|
if source in existing or is_go2rtc_arbitrary_exec_allowed():
|
||||||
continue
|
continue
|
||||||
issues[name] = Go2rtcStreamIssue.restricted
|
issues[name] = Go2rtcStreamIssue.restricted
|
||||||
break
|
break
|
||||||
|
|
||||||
# only sources whose placeholders resolve here are accepted, so the
|
# the resolved value checked below is what go2rtc loads at startup
|
||||||
# resolved value checked below is what go2rtc loads at startup
|
|
||||||
try:
|
try:
|
||||||
|
with candidate_env_vars(new_env_vars):
|
||||||
resolved_source = substitute_frigate_vars(source)
|
resolved_source = substitute_frigate_vars(source)
|
||||||
except UnknownVariableError:
|
except UnknownVariableError:
|
||||||
issues[name] = Go2rtcStreamIssue.unknown_variable
|
issues[name] = Go2rtcStreamIssue.unknown_variable
|
||||||
@@ -1272,6 +1284,11 @@ def find_restricted_go2rtc_stream_changes(
|
|||||||
issues[name] = Go2rtcStreamIssue.invalid_placeholder
|
issues[name] = Go2rtcStreamIssue.invalid_placeholder
|
||||||
break
|
break
|
||||||
|
|
||||||
|
if source in existing and resolved_source == (
|
||||||
|
_resolve_running_frigate_vars(source)
|
||||||
|
):
|
||||||
|
continue
|
||||||
|
|
||||||
if is_restricted_go2rtc_api_source(
|
if is_restricted_go2rtc_api_source(
|
||||||
source
|
source
|
||||||
) or is_restricted_go2rtc_api_source(resolved_source):
|
) or is_restricted_go2rtc_api_source(resolved_source):
|
||||||
|
|||||||
@@ -23,15 +23,17 @@ Some examples (model - class or model name)::
|
|||||||
|
|
||||||
import peewee as pw
|
import peewee as pw
|
||||||
|
|
||||||
|
from frigate.models import Event
|
||||||
|
|
||||||
SQL = pw.SQL
|
SQL = pw.SQL
|
||||||
|
|
||||||
|
|
||||||
def migrate(migrator, database, fake=False, **kwargs):
|
def migrate(migrator, database, fake=False, **kwargs):
|
||||||
# raw SQL keeps the dropped field off the Event model (removed in 041)
|
migrator.add_fields(
|
||||||
migrator.sql(
|
Event,
|
||||||
'ALTER TABLE "event" ADD COLUMN "retain_indefinitely" INTEGER NOT NULL DEFAULT 0'
|
retain_indefinitely=pw.BooleanField(default=False),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def rollback(migrator, database, fake=False, **kwargs):
|
def rollback(migrator, database, fake=False, **kwargs):
|
||||||
migrator.sql('ALTER TABLE "event" DROP COLUMN "retain_indefinitely"')
|
migrator.remove_fields(Event, ["retain_indefinitely"])
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
"""Peewee migrations -- 041_remove_retain_indefinitely.py."""
|
|
||||||
|
|
||||||
import peewee as pw
|
|
||||||
|
|
||||||
SQL = pw.SQL
|
|
||||||
|
|
||||||
|
|
||||||
def migrate(migrator, database, fake=False, **kwargs):
|
|
||||||
migrator.sql('ALTER TABLE "event" DROP COLUMN "retain_indefinitely"')
|
|
||||||
|
|
||||||
|
|
||||||
def rollback(migrator, database, fake=False, **kwargs):
|
|
||||||
migrator.sql(
|
|
||||||
'ALTER TABLE "event" ADD COLUMN "retain_indefinitely" INTEGER NOT NULL DEFAULT 0'
|
|
||||||
)
|
|
||||||
@@ -1 +1 @@
|
|||||||
[{"id": "event-person-001", "label": "person", "sub_label": null, "camera": "front_door", "start_time": 1780677009.365581, "end_time": 1780677039.365581, "false_positive": false, "zones": ["front_yard"], "thumbnail": null, "has_clip": true, "has_snapshot": true, "plus_id": null, "model_hash": "abc123", "detector_type": "cpu", "model_type": "ssd", "data": {"top_score": 0.92, "score": 0.92, "region": [0.1, 0.1, 0.5, 0.8], "box": [0.2, 0.15, 0.45, 0.75], "area": 0.18, "ratio": 0.6, "type": "object", "description": "A person walking toward the front door", "average_estimated_speed": 1.2, "velocity_angle": 45.0, "path_data": [[[0.2, 0.5], 0.0], [[0.3, 0.5], 1.0]]}}, {"id": "event-car-001", "label": "car", "sub_label": null, "camera": "backyard", "start_time": 1780673409.365581, "end_time": 1780673454.365581, "false_positive": false, "zones": ["driveway"], "thumbnail": null, "has_clip": true, "has_snapshot": true, "plus_id": null, "model_hash": "def456", "detector_type": "cpu", "model_type": "ssd", "data": {"top_score": 0.87, "score": 0.87, "region": [0.3, 0.2, 0.9, 0.7], "box": [0.35, 0.25, 0.85, 0.65], "area": 0.2, "ratio": 1.25, "type": "object", "description": "A car parked in the driveway", "average_estimated_speed": 0.0, "velocity_angle": 0.0, "path_data": []}}, {"id": "event-person-002", "label": "person", "sub_label": null, "camera": "garage", "start_time": 1780669809.365581, "end_time": 1780669829.365581, "false_positive": false, "zones": [], "thumbnail": null, "has_clip": false, "has_snapshot": true, "plus_id": null, "model_hash": "ghi789", "detector_type": "cpu", "model_type": "ssd", "data": {"top_score": 0.78, "score": 0.78, "region": [0.0, 0.0, 0.6, 0.9], "box": [0.1, 0.05, 0.5, 0.85], "area": 0.32, "ratio": 0.5, "type": "object", "description": null, "average_estimated_speed": 0.5, "velocity_angle": 90.0, "path_data": [[[0.1, 0.4], 0.0]]}}]
|
[{"id": "event-person-001", "label": "person", "sub_label": null, "camera": "front_door", "start_time": 1780677009.365581, "end_time": 1780677039.365581, "false_positive": false, "zones": ["front_yard"], "thumbnail": null, "has_clip": true, "has_snapshot": true, "retain_indefinitely": false, "plus_id": null, "model_hash": "abc123", "detector_type": "cpu", "model_type": "ssd", "data": {"top_score": 0.92, "score": 0.92, "region": [0.1, 0.1, 0.5, 0.8], "box": [0.2, 0.15, 0.45, 0.75], "area": 0.18, "ratio": 0.6, "type": "object", "description": "A person walking toward the front door", "average_estimated_speed": 1.2, "velocity_angle": 45.0, "path_data": [[[0.2, 0.5], 0.0], [[0.3, 0.5], 1.0]]}}, {"id": "event-car-001", "label": "car", "sub_label": null, "camera": "backyard", "start_time": 1780673409.365581, "end_time": 1780673454.365581, "false_positive": false, "zones": ["driveway"], "thumbnail": null, "has_clip": true, "has_snapshot": true, "retain_indefinitely": false, "plus_id": null, "model_hash": "def456", "detector_type": "cpu", "model_type": "ssd", "data": {"top_score": 0.87, "score": 0.87, "region": [0.3, 0.2, 0.9, 0.7], "box": [0.35, 0.25, 0.85, 0.65], "area": 0.2, "ratio": 1.25, "type": "object", "description": "A car parked in the driveway", "average_estimated_speed": 0.0, "velocity_angle": 0.0, "path_data": []}}, {"id": "event-person-002", "label": "person", "sub_label": null, "camera": "garage", "start_time": 1780669809.365581, "end_time": 1780669829.365581, "false_positive": false, "zones": [], "thumbnail": null, "has_clip": false, "has_snapshot": true, "retain_indefinitely": false, "plus_id": null, "model_hash": "ghi789", "detector_type": "cpu", "model_type": "ssd", "data": {"top_score": 0.78, "score": 0.78, "region": [0.0, 0.0, 0.6, 0.9], "box": [0.1, 0.05, 0.5, 0.85], "area": 0.32, "ratio": 0.5, "type": "object", "description": null, "average_estimated_speed": 0.5, "velocity_angle": 90.0, "path_data": [[[0.1, 0.4], 0.0]]}}]
|
||||||
@@ -234,6 +234,7 @@ def generate_events():
|
|||||||
thumbnail=None,
|
thumbnail=None,
|
||||||
has_clip=True,
|
has_clip=True,
|
||||||
has_snapshot=True,
|
has_snapshot=True,
|
||||||
|
retain_indefinitely=False,
|
||||||
plus_id=None,
|
plus_id=None,
|
||||||
model_hash="abc123",
|
model_hash="abc123",
|
||||||
detector_type="cpu",
|
detector_type="cpu",
|
||||||
@@ -264,6 +265,7 @@ def generate_events():
|
|||||||
thumbnail=None,
|
thumbnail=None,
|
||||||
has_clip=True,
|
has_clip=True,
|
||||||
has_snapshot=True,
|
has_snapshot=True,
|
||||||
|
retain_indefinitely=False,
|
||||||
plus_id=None,
|
plus_id=None,
|
||||||
model_hash="def456",
|
model_hash="def456",
|
||||||
detector_type="cpu",
|
detector_type="cpu",
|
||||||
@@ -294,6 +296,7 @@ def generate_events():
|
|||||||
thumbnail=None,
|
thumbnail=None,
|
||||||
has_clip=False,
|
has_clip=False,
|
||||||
has_snapshot=True,
|
has_snapshot=True,
|
||||||
|
retain_indefinitely=False,
|
||||||
plus_id=None,
|
plus_id=None,
|
||||||
model_hash="ghi789",
|
model_hash="ghi789",
|
||||||
detector_type="cpu",
|
detector_type="cpu",
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ const GROUPED_EVENT = {
|
|||||||
thumbnail: null,
|
thumbnail: null,
|
||||||
has_clip: true,
|
has_clip: true,
|
||||||
has_snapshot: true,
|
has_snapshot: true,
|
||||||
|
retain_indefinitely: false,
|
||||||
plus_id: null,
|
plus_id: null,
|
||||||
model_hash: "abc123",
|
model_hash: "abc123",
|
||||||
detector_type: "cpu",
|
detector_type: "cpu",
|
||||||
@@ -425,6 +426,7 @@ test.describe("FaceSelectionDialog @high", () => {
|
|||||||
thumbnail: null,
|
thumbnail: null,
|
||||||
has_clip: true,
|
has_clip: true,
|
||||||
has_snapshot: true,
|
has_snapshot: true,
|
||||||
|
retain_indefinitely: false,
|
||||||
plus_id: null,
|
plus_id: null,
|
||||||
model_hash: "abc123",
|
model_hash: "abc123",
|
||||||
detector_type: "cpu",
|
detector_type: "cpu",
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ export interface Event {
|
|||||||
thumbnail: string;
|
thumbnail: string;
|
||||||
has_clip: boolean;
|
has_clip: boolean;
|
||||||
has_snapshot: boolean;
|
has_snapshot: boolean;
|
||||||
|
retain_indefinitely: boolean;
|
||||||
plus_id?: string;
|
plus_id?: string;
|
||||||
model_hash?: string;
|
model_hash?: string;
|
||||||
data: {
|
data: {
|
||||||
|
|||||||
Reference in New Issue
Block a user