✨ File extension stored in an enum. File exists check refactored to explicit extension check.

This commit is contained in:
Robert Honz
2024-01-17 22:08:39 +01:00
parent bdccb8be37
commit 62c75e6c97
5 changed files with 44 additions and 21 deletions
+6 -3
View File
@@ -19,9 +19,13 @@ class BaseConfig:
cls_model: object = None
path_base: str = path_base()
def save(self) -> None:
def save(self, config_to_compare: str = None) -> None:
data_json = self.data.to_json()
# If old and current config is equal, skip the write operation.
if config_to_compare == data_json:
return
# Try to create the base folder.
os.makedirs(self.path_base, exist_ok=True)
@@ -59,8 +63,7 @@ class BaseConfig:
self.data = self.cls_model()
# Call save in case of we need to update the saved config, due to changes in code.
# TODO: Compare if config in memory and on disk is different. Otherwise no write operation.
self.save()
self.save(settings_json)
return result