Fix save_custom_configs method in Database.py with autoconf and other services

This commit is contained in:
Théophile Diot 2024-03-24 09:45:59 +00:00
parent a3bde2336f
commit 330048ecf6
No known key found for this signature in database
GPG key ID: 248FEA4BAE400D06

View file

@ -962,7 +962,21 @@ class Database:
def save_custom_configs(
self,
custom_configs: List[Dict[str, Union[str, bytes, Tuple[str, List[str]]]]],
custom_configs: List[
Dict[
Literal[
"service_id",
"type",
"name",
"data",
"value",
"checksum",
"method",
"exploded",
],
Union[str, bytes, List[str]],
]
],
method: str,
changed: Optional[bool] = True,
) -> str:
@ -976,11 +990,7 @@ class Database:
endl = "\n"
for custom_config in custom_configs:
if method != "ui":
config = {
"data": custom_config["value"],
"method": method,
}
assert isinstance(custom_config["exploded"], tuple) and len(custom_config["exploded"]) == 3, "Invalid exploded custom config"
config = {"data": custom_config["value"], "method": method}
if custom_config["exploded"][0]:
if not session.query(Services).with_entities(Services.id).filter_by(id=custom_config["exploded"][0]).first():