falling back to defaults for broken configs

This commit is contained in:
sezanzeb 2021-02-15 18:27:34 +01:00 committed by sezanzeb
parent 6c1c21e0ab
commit 0a676e7fc5

View File

@ -248,10 +248,11 @@ class GlobalConfig(ConfigBase):
logger.info('Loaded config from "%s"', self.path) logger.info('Loaded config from "%s"', self.path)
except json.decoder.JSONDecodeError as error: except json.decoder.JSONDecodeError as error:
logger.error( logger.error(
'Failed to parse config "%s": %s', 'Failed to parse config "%s": %s. Using defaults',
self.path, str(error) self.path, str(error)
) )
sys.exit(1) # uses the default configuration when the config object
# is empty automatically
def save_config(self): def save_config(self):
"""Save the config to the file system.""" """Save the config to the file system."""
@ -264,7 +265,6 @@ class GlobalConfig(ConfigBase):
with open(self.path, 'w') as file: with open(self.path, 'w') as file:
json.dump(self._config, file, indent=4) json.dump(self._config, file, indent=4)
logger.info('Saved config to %s', self.path) logger.info('Saved config to %s', self.path)
shutil.chown(self.path, USER, USER)
file.write('\n') file.write('\n')