mirror of
https://github.com/aclist/dztui.git
synced 2026-10-25 12:12:31 +01:00
Merge pull request #499 from aclist/fix/vdf-missing
Mirror to Codeberg / mirror-to-codeberg (push) Canceled after 0s
Mirror to Codeberg / mirror-to-codeberg (push) Canceled after 0s
fix: missing shortcuts file
This commit is contained in:
1 file changed
+10
-3
+10
-3
@@ -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
|
||||||
@@ -109,6 +111,7 @@ class Shortcuts:
|
|||||||
for img in ("_hero", "p", "_logo"):
|
for img in ("_hero", "p", "_logo"):
|
||||||
filename = str(self.bpid) + img
|
filename = str(self.bpid) + img
|
||||||
dest = grid_path.joinpath(filename).with_suffix(".png")
|
dest = grid_path.joinpath(filename).with_suffix(".png")
|
||||||
|
make_parents(dest)
|
||||||
b = images.joinpath(img).with_suffix(".png").read_bytes()
|
b = images.joinpath(img).with_suffix(".png").read_bytes()
|
||||||
dest.write_bytes(b)
|
dest.write_bytes(b)
|
||||||
|
|
||||||
@@ -155,7 +158,8 @@ class Shortcuts:
|
|||||||
NEW_ENTRY["DevkitGameID"] = ""
|
NEW_ENTRY["DevkitGameID"] = ""
|
||||||
NEW_ENTRY["DevkitOverrideAppID"] = 0
|
NEW_ENTRY["DevkitOverrideAppID"] = 0
|
||||||
NEW_ENTRY["LastPlayTime"] = 0
|
NEW_ENTRY["LastPlayTime"] = 0
|
||||||
NEW_ENTRY["FlatpakAppID"] = ""
|
NEW_ENTRY["FlatpakAppID"] = GTK_APP_ID
|
||||||
|
|
||||||
NEW_ENTRY["sortas"] = ""
|
NEW_ENTRY["sortas"] = ""
|
||||||
NEW_ENTRY["tags"] = {}
|
NEW_ENTRY["tags"] = {}
|
||||||
return NEW_ENTRY
|
return NEW_ENTRY
|
||||||
@@ -172,6 +176,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