From c2cfe2b4d92bf572f6bc2d10fee0ccdddeb25031 Mon Sep 17 00:00:00 2001 From: aclist <92275929+aclist@users.noreply.github.com> Date: Fri, 23 Oct 2026 11:34:52 +0900 Subject: [PATCH] fix: handle missing shortcut file --- dzgui/api/shortcuts.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/dzgui/api/shortcuts.py b/dzgui/api/shortcuts.py index 594d1a1..5d76d00 100644 --- a/dzgui/api/shortcuts.py +++ b/dzgui/api/shortcuts.py @@ -10,8 +10,8 @@ from pathlib import Path from typing import Any from dzgui.api.steam import find_user_id_32 -from dzgui.const.constants import APP_NAME, APP_NAME_LOWER, IMAGES_PATH -from dzgui.util.dirs import copy_dzgui_to_xdg_data +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, make_parents from dzgui.util.strings import unknown logger = logging.getLogger(APP_NAME) @@ -75,6 +75,8 @@ class Shortcuts: shortcuts = vdf.binary_load(f) self.shortcuts = shortcuts logger.debug("Loaded shortcuts file") + except FileNotFoundError: + self.shortcuts = {"shortcuts": {}} except Exception as e: logger.critical(e) raise e @@ -172,6 +174,9 @@ class Shortcuts: try: backup = self.shortcuts_path.with_suffix(".vdf.bak") shutil.copy(self.shortcuts_path, backup) + except Exception as e: + logger.critical(e) + try: with open(self.shortcuts_path, "wb") as f: vdf.binary_dump(self.shortcuts, f) except Exception as e: