mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-03 17:55:21 +03:00
Fixes
This commit is contained in:
parent
90aff208fc
commit
b28dcf4b5e
@ -710,6 +710,8 @@ def config_raw():
|
|||||||
|
|
||||||
@bp.route("/config/save", methods=["POST"])
|
@bp.route("/config/save", methods=["POST"])
|
||||||
def config_save():
|
def config_save():
|
||||||
|
save_option = request.headers.get('Save-Option')
|
||||||
|
|
||||||
new_config = request.get_data().decode()
|
new_config = request.get_data().decode()
|
||||||
|
|
||||||
if not new_config:
|
if not new_config:
|
||||||
@ -753,6 +755,7 @@ def config_save():
|
|||||||
400,
|
400,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(save_option == "restart"):
|
||||||
try:
|
try:
|
||||||
restart_frigate()
|
restart_frigate()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@ -760,55 +763,8 @@ def config_save():
|
|||||||
return "Config successfully saved, unable to restart Frigate", 200
|
return "Config successfully saved, unable to restart Frigate", 200
|
||||||
|
|
||||||
return "Config successfully saved, restarting...", 200
|
return "Config successfully saved, restarting...", 200
|
||||||
|
else:
|
||||||
|
return "Config successfully saved.", 200
|
||||||
@bp.route("/config/saveonly", methods=["POST"])
|
|
||||||
def config_save():
|
|
||||||
new_config = request.get_data().decode()
|
|
||||||
|
|
||||||
if not new_config:
|
|
||||||
return "Config with body param is required", 400
|
|
||||||
|
|
||||||
# Validate the config schema
|
|
||||||
try:
|
|
||||||
new_yaml = FrigateConfig.parse_raw(new_config)
|
|
||||||
except Exception as e:
|
|
||||||
return make_response(
|
|
||||||
jsonify(
|
|
||||||
{
|
|
||||||
"success": False,
|
|
||||||
"message": f"\nConfig Error:\n\n{str(traceback.format_exc())}",
|
|
||||||
}
|
|
||||||
),
|
|
||||||
400,
|
|
||||||
)
|
|
||||||
|
|
||||||
# Save the config to file
|
|
||||||
try:
|
|
||||||
config_file = os.environ.get("CONFIG_FILE", "/config/config.yml")
|
|
||||||
|
|
||||||
# Check if we can use .yaml instead of .yml
|
|
||||||
config_file_yaml = config_file.replace(".yml", ".yaml")
|
|
||||||
|
|
||||||
if os.path.isfile(config_file_yaml):
|
|
||||||
config_file = config_file_yaml
|
|
||||||
|
|
||||||
with open(config_file, "w") as f:
|
|
||||||
f.write(new_config)
|
|
||||||
f.close()
|
|
||||||
except Exception as e:
|
|
||||||
return make_response(
|
|
||||||
jsonify(
|
|
||||||
{
|
|
||||||
"success": False,
|
|
||||||
"message": f"Could not write config file, be sure that Frigate has write permission on the config file.",
|
|
||||||
}
|
|
||||||
),
|
|
||||||
400,
|
|
||||||
)
|
|
||||||
|
|
||||||
return "Config successfully saved", 200
|
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/config/schema.json")
|
@bp.route("/config/schema.json")
|
||||||
def config_schema():
|
def config_schema():
|
||||||
|
|||||||
@ -24,7 +24,7 @@ export default function Config() {
|
|||||||
|
|
||||||
axios
|
axios
|
||||||
.post('config/save', window.editor.getValue(), {
|
.post('config/save', window.editor.getValue(), {
|
||||||
headers: { 'Content-Type': 'text/plain' },
|
headers: { 'Content-Type': 'text/plain', 'Save-Option': 'restart' },
|
||||||
})
|
})
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
if (response.status === 200) {
|
if (response.status === 200) {
|
||||||
@ -46,8 +46,8 @@ export default function Config() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
axios
|
axios
|
||||||
.post('config/saveonly', window.editor.getValue(), {
|
.post('config/save', window.editor.getValue(), {
|
||||||
headers: { 'Content-Type': 'text/plain' },
|
headers: { 'Content-Type': 'text/plain', 'Save-Option': 'saveonly' },
|
||||||
})
|
})
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
if (response.status === 200) {
|
if (response.status === 200) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user