mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-02-09 00:17:00 +01:00
More api fixes (#13936)
* Set correect return type for raw config * Simplify parsing * Formatting
This commit is contained in:
parent
a8e2f97260
commit
a9ff795948
@ -160,7 +160,9 @@ def config_raw():
|
|||||||
raw_config = f.read()
|
raw_config = f.read()
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
return raw_config, 200
|
return JSONResponse(
|
||||||
|
content=raw_config, media_type="text/plain", status_code=200
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@router.post("/config/save")
|
@router.post("/config/save")
|
||||||
@ -259,13 +261,13 @@ def config_set(request: Request, body: AppConfigSetBody):
|
|||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
update_yaml_from_url(config_file, request.url)
|
update_yaml_from_url(config_file, str(request.url))
|
||||||
with open(config_file, "r") as f:
|
with open(config_file, "r") as f:
|
||||||
new_raw_config = f.read()
|
new_raw_config = f.read()
|
||||||
f.close()
|
f.close()
|
||||||
# Validate the config schema
|
# Validate the config schema
|
||||||
try:
|
try:
|
||||||
config_obj = FrigateConfig.parse_yaml(new_raw_config)
|
config = FrigateConfig.parse(new_raw_config)
|
||||||
except Exception:
|
except Exception:
|
||||||
with open(config_file, "w") as f:
|
with open(config_file, "w") as f:
|
||||||
f.write(old_raw_config)
|
f.write(old_raw_config)
|
||||||
@ -288,10 +290,7 @@ def config_set(request: Request, body: AppConfigSetBody):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if body.requires_restart == 0:
|
if body.requires_restart == 0:
|
||||||
request.app.frigate_config = FrigateConfig.parse_object(
|
request.app.frigate_config = config
|
||||||
config_obj, request.app.frigate_config.plus_api
|
|
||||||
)
|
|
||||||
|
|
||||||
return JSONResponse(
|
return JSONResponse(
|
||||||
content=(
|
content=(
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user