Refactor main.py to handle custom config retrieval and handling more efficiently

This commit is contained in:
Théophile Diot 2024-09-17 11:48:16 +02:00
parent 50c3b9473f
commit 086de4fb54
No known key found for this signature in database
GPG key ID: FA995104A0BA376A

View file

@ -615,13 +615,16 @@ if __name__ == "__main__":
saving = True
in_db = False
from_template = False
for db_conf in db_configs:
if db_conf["service_id"] == service_id and db_conf["name"] == file.stem:
in_db = True
if db_conf["template"]:
from_template = True
if not in_db and content.startswith("# CREATED BY ENV"):
if from_template or (not in_db and content.startswith("# CREATED BY ENV")):
saving = False
changes = True
changes = not from_template
if saving:
custom_configs.append({"value": content, "exploded": (service_id, config_type, file.stem)})