Move config saving to own method.
This commit is contained in:
parent
269cfb6762
commit
941d50eae0
1 changed files with 10 additions and 3 deletions
|
@ -1184,12 +1184,19 @@ class PhotoDB(
|
||||||
stored_keys = helpers.recursive_dict_keys(user_config)
|
stored_keys = helpers.recursive_dict_keys(user_config)
|
||||||
needs_dump = not my_keys.issubset(stored_keys)
|
needs_dump = not my_keys.issubset(stored_keys)
|
||||||
helpers.recursive_dict_update(target=config, supply=user_config)
|
helpers.recursive_dict_update(target=config, supply=user_config)
|
||||||
|
else:
|
||||||
|
needs_dump = True
|
||||||
|
|
||||||
if (not user_config_exists) or needs_dump:
|
if needs_dump:
|
||||||
with open(self.config_filepath.absolute_path, 'w') as handle:
|
self._save_config()
|
||||||
handle.write(json.dumps(config, indent=4, sort_keys=True))
|
|
||||||
|
self.config = config
|
||||||
return config
|
return config
|
||||||
|
|
||||||
|
def _save_config(self):
|
||||||
|
with open(self.config_filepath.absolute_path, 'w') as handle:
|
||||||
|
handle.write(json.dumps(self.config, indent=4, sort_keys=True))
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
self.close()
|
self.close()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue