Catch exceptions when writing metadata to file

This commit is contained in:
David Vildebrand 2023-05-27 11:44:16 +02:00
parent a70ac2d1f9
commit 364afd0ba5

View file

@ -229,7 +229,11 @@ class LGDLFS:
json_meta = meta.__dict__
self._game_metadata[app_name] = json_meta
meta_file = os.path.join(self.path, 'metadata', f'{app_name}.json')
json.dump(json_meta, open(meta_file, 'w'), indent=2, sort_keys=True)
try:
json.dump(json_meta, open(meta_file, 'w'), indent=2, sort_keys=True)
except OSError as e:
self.log.error(f'Unable to write metadata to file: "{meta_file}" ! '
f'(Error: {repr(e)})')
def delete_game_meta(self, app_name):
if app_name not in self._game_metadata: