mirror of
https://github.com/aclist/dztui.git
synced 2026-10-25 12:12:31 +01:00
fix: handle missing shortcut file
This commit is contained in:
1 parent
5cb8c68f5c
commit
c2cfe2b4d9
1 file changed
+7
-2
@@ -10,8 +10,8 @@ from pathlib import Path
|
|||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from dzgui.api.steam import find_user_id_32
|
from dzgui.api.steam import find_user_id_32
|
||||||
from dzgui.const.constants import APP_NAME, APP_NAME_LOWER, IMAGES_PATH
|
from dzgui.const.constants import APP_NAME, APP_NAME_LOWER, GTK_APP_ID, IMAGES_PATH
|
||||||
from dzgui.util.dirs import copy_dzgui_to_xdg_data
|
from dzgui.util.dirs import copy_dzgui_to_xdg_data, make_parents
|
||||||
from dzgui.util.strings import unknown
|
from dzgui.util.strings import unknown
|
||||||
|
|
||||||
logger = logging.getLogger(APP_NAME)
|
logger = logging.getLogger(APP_NAME)
|
||||||
@@ -75,6 +75,8 @@ class Shortcuts:
|
|||||||
shortcuts = vdf.binary_load(f)
|
shortcuts = vdf.binary_load(f)
|
||||||
self.shortcuts = shortcuts
|
self.shortcuts = shortcuts
|
||||||
logger.debug("Loaded shortcuts file")
|
logger.debug("Loaded shortcuts file")
|
||||||
|
except FileNotFoundError:
|
||||||
|
self.shortcuts = {"shortcuts": {}}
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.critical(e)
|
logger.critical(e)
|
||||||
raise e
|
raise e
|
||||||
@@ -172,6 +174,9 @@ class Shortcuts:
|
|||||||
try:
|
try:
|
||||||
backup = self.shortcuts_path.with_suffix(".vdf.bak")
|
backup = self.shortcuts_path.with_suffix(".vdf.bak")
|
||||||
shutil.copy(self.shortcuts_path, backup)
|
shutil.copy(self.shortcuts_path, backup)
|
||||||
|
except Exception as e:
|
||||||
|
logger.critical(e)
|
||||||
|
try:
|
||||||
with open(self.shortcuts_path, "wb") as f:
|
with open(self.shortcuts_path, "wb") as f:
|
||||||
vdf.binary_dump(self.shortcuts, f)
|
vdf.binary_dump(self.shortcuts, f)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
Reference in new issue
Block a user