app no longer crashes if config is invalid json (#66 gnomegitlab)

parent da99fc4d
Pipeline #250748 passed with stage
in 11 minutes and 8 seconds
......@@ -142,7 +142,7 @@ class ConfManager(metaclass=Singleton):
self.save_conf()
except Exception:
self.conf = ConfManager.BASE_SCHEMA.copy()
self.save_conf()
self.save_conf(force_overwrite=True)
else:
self.conf = ConfManager.BASE_SCHEMA.copy()
self.save_conf()
......@@ -227,8 +227,8 @@ class ConfManager(metaclass=Singleton):
def dump_read_items_to_conf(self, *args):
self.conf['read_items'] = self.read_feeds_items.get_list()
def save_conf(self, *args):
if self.path.is_file():
def save_conf(self, *args, force_overwrite=False):
if self.path.is_file() and not force_overwrite:
with open(self.path, 'r') as fd:
if json.loads(fd.read()) == self.conf:
return
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment