Fix JSONConfigFile read() when no file exists

This commit is contained in:
miruka 2019-07-24 19:56:23 -04:00
parent a2469bd994
commit 504644e641

View File

@ -34,10 +34,7 @@ class ConfigFile:
async def read(self): async def read(self):
try: return self.path.read_text()
return self.path.read_text()
except FileNotFoundError:
return await self.default_data()
async def write(self, data) -> None: async def write(self, data) -> None:
@ -57,7 +54,7 @@ class JSONConfigFile(ConfigFile):
async def read(self) -> JsonData: async def read(self) -> JsonData:
try: try:
data = json.loads(await super().read()) data = json.loads(await super().read())
except json.JSONDecodeError: except (FileNotFoundError, json.JSONDecodeError):
data = {} data = {}
all_data = await self.default_data() all_data = await self.default_data()