Fix redundant code and improve error handling in manage_bunkerweb function

This commit is contained in:
Théophile Diot 2024-05-22 15:31:20 +01:00
parent 3437d8610e
commit dd0574aa78
No known key found for this signature in database
GPG key ID: 248FEA4BAE400D06
2 changed files with 2 additions and 7 deletions

View file

@ -201,7 +201,6 @@ def manage_bunkerweb(method: str, *args, operation: str = "reloads", is_draft: b
# Do the operation
error = 0
ui_data = get_ui_data()
operation = ""
if "TO_FLASH" not in ui_data:
ui_data["TO_FLASH"] = []
@ -214,11 +213,7 @@ def manage_bunkerweb(method: str, *args, operation: str = "reloads", is_draft: b
elif operation == "delete":
operation, error = app.config["CONFIG"].delete_service(args[2], check_changes=(was_draft != is_draft or not is_draft))
if error:
ui_data["TO_FLASH"].append({"content": operation, "type": "error"})
else:
ui_data["TO_FLASH"].append({"content": operation, "type": "success"})
if not error:
if was_draft != is_draft or not is_draft:
# update changes in db
ret = db.checked_changes(["config", "custom_configs"], value=True)

View file

@ -136,7 +136,7 @@ class Config:
return error
def reload_config(self) -> str:
def reload_config(self) -> Optional[str]:
return self.__gen_conf(self.get_config(methods=False), self.get_services(methods=False))
def new_service(self, variables: dict, is_draft: bool = False) -> Tuple[str, int]: