diff options
| author | Robert Honz <exislow+github@gmail.com> | 2024-01-17 22:08:39 +0100 |
|---|---|---|
| committer | Robert Honz <exislow+github@gmail.com> | 2024-01-17 22:08:39 +0100 |
| commit | 62c75e6c972eed4aadaba3dd03e60d63c31eb995 (patch) | |
| tree | e71f22c5757a0e81cf157016d8f9de26234054f3 /tidal_dl_ng/config.py | |
| parent | bdccb8be37fd941cd5c681950a7e25085efbabb0 (diff) | |
| download | tidal-dl-ng-62c75e6c972eed4aadaba3dd03e60d63c31eb995.tar.gz | |
✨ File extension stored in an enum. File exists check refactored to explicit extension check.
Diffstat (limited to 'tidal_dl_ng/config.py')
| -rw-r--r-- | tidal_dl_ng/config.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/tidal_dl_ng/config.py b/tidal_dl_ng/config.py index 2fed1ce..fcf8291 100644 --- a/tidal_dl_ng/config.py +++ b/tidal_dl_ng/config.py @@ -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 |
