Refactor Database.py to simplify service setting handling

This commit is contained in:
Théophile Diot 2024-10-24 16:24:14 +02:00
parent b73861db5e
commit 61f8b834eb
No known key found for this signature in database
GPG key ID: FA995104A0BA376A

View file

@ -1450,14 +1450,12 @@ class Database:
# Determine if we need to add, update, or delete
if not service_setting:
if key != "SERVER_NAME" and (
(template_setting_default is not None and value == template_setting_default)
or (
template_setting_default is None
and (
(original_key in config and value == config[original_key])
or (original_key in db_config and value == db_config[original_key])
or value == setting["default"]
)
value == template_setting_default
if template_setting_default is not None
else (
value == setting["default"]
if original_key not in config and original_key not in db_config
else value in (config.get(original_key), db_config.get(original_key))
)
):
continue
@ -1475,14 +1473,12 @@ class Database:
local_changed_plugins.add(setting["plugin_id"])
if key != "SERVER_NAME" and (
(template_setting_default is not None and value == template_setting_default)
or (
template_setting_default is None
and (
(original_key in config and value == config[original_key])
or (original_key in db_config and value == db_config[original_key])
or value == setting["default"]
)
value == template_setting_default
if template_setting_default is not None
else (
value == setting["default"]
if original_key not in config and original_key not in db_config
else value in (config.get(original_key), db_config.get(original_key))
)
):
self.logger.debug(f"Removing setting {key} for service {server_name}")