Fix handling errors in config files on startup
This commit is contained in:
parent
f9d1ec6e8a
commit
69a338f610
|
@ -48,13 +48,16 @@ class UserFile:
|
||||||
_writer: Optional[asyncio.Future] = field(init=False, default=None)
|
_writer: Optional[asyncio.Future] = field(init=False, default=None)
|
||||||
|
|
||||||
def __post_init__(self) -> None:
|
def __post_init__(self) -> None:
|
||||||
if self.path.exists():
|
|
||||||
text = self.path.read_text()
|
|
||||||
self.data, self._need_write = self.deserialized(text)
|
|
||||||
else:
|
|
||||||
self.data = self.default_data
|
self.data = self.default_data
|
||||||
self._need_write = self.create_missing
|
self._need_write = self.create_missing
|
||||||
|
|
||||||
|
if self.path.exists():
|
||||||
|
try:
|
||||||
|
text = self.path.read_text()
|
||||||
|
self.data, self._need_write = self.deserialized(text)
|
||||||
|
except Exception as err: # noqa
|
||||||
|
LoopException(str(err), err, traceback.format_exc().rstrip())
|
||||||
|
|
||||||
self._reader = asyncio.ensure_future(self._start_reader())
|
self._reader = asyncio.ensure_future(self._start_reader())
|
||||||
self._writer = asyncio.ensure_future(self._start_writer())
|
self._writer = asyncio.ensure_future(self._start_writer())
|
||||||
|
|
||||||
|
@ -414,7 +417,9 @@ class Settings(ConfigFile, PCNFile):
|
||||||
section, save = super().deserialized(data)
|
section, save = super().deserialized(data)
|
||||||
|
|
||||||
if self and self.General.theme != section.General.theme:
|
if self and self.General.theme != section.General.theme:
|
||||||
|
if hasattr(self.backend, "theme"):
|
||||||
self.backend.theme.stop_watching()
|
self.backend.theme.stop_watching()
|
||||||
|
|
||||||
self.backend.theme = Theme(
|
self.backend.theme = Theme(
|
||||||
self.backend, section.General.theme, # type: ignore
|
self.backend, section.General.theme, # type: ignore
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user