From 8bc1c1c58c911a77f129a406937b76d8a7cc3dd4 Mon Sep 17 00:00:00 2001 From: Zamitto <167933696+zamitto@users.noreply.github.com> Date: Mon, 1 Sep 2025 21:39:41 -0300 Subject: [PATCH] fix: handle error on getting steam path from windows registry --- package.json | 2 +- src/main/events/library/create-steam-shortcut.ts | 2 +- .../services/achievements/find-achivement-files.ts | 6 +++++- src/main/services/steam.ts | 10 +++++++++- src/renderer/src/pages/catalogue/game-item.tsx | 4 +++- 5 files changed, 19 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index ed7e31e0..345e514b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hydralauncher", - "version": "3.6.4", + "version": "3.6.5", "description": "Hydra", "main": "./out/main/index.js", "author": "Los Broxas", diff --git a/src/main/events/library/create-steam-shortcut.ts b/src/main/events/library/create-steam-shortcut.ts index faa69266..b12d503f 100644 --- a/src/main/events/library/create-steam-shortcut.ts +++ b/src/main/events/library/create-steam-shortcut.ts @@ -94,7 +94,7 @@ const createSteamShortcut = async ( if (!steamUserIds.length) { logger.error("No Steam user ID found"); - return; + throw new Error("No Steam user ID found"); } const [iconImage, heroImage, logoImage, coverImage, libraryImage] = diff --git a/src/main/services/achievements/find-achivement-files.ts b/src/main/services/achievements/find-achivement-files.ts index 26d44170..96e0fd33 100644 --- a/src/main/services/achievements/find-achivement-files.ts +++ b/src/main/services/achievements/find-achivement-files.ts @@ -279,13 +279,17 @@ export const findAchievementFiles = (game: Game) => { }; const steamUserIds = await getSteamUsersIds(); -const steamPath = await getSteamLocation(); +const steamPath = await getSteamLocation().catch(() => null); export const findAchievementFileInSteamPath = async (game: Game) => { if (!steamUserIds.length) { return []; } + if (!steamPath) { + return []; + } + const userPreferences = await db.get( levelKeys.userPreferences, { diff --git a/src/main/services/steam.ts b/src/main/services/steam.ts index 70653fd0..0049d710 100644 --- a/src/main/services/steam.ts +++ b/src/main/services/steam.ts @@ -42,6 +42,10 @@ export const getSteamLocation = async () => { reject(err); } + if (!value) { + reject(new Error("SteamPath not found in registry")); + } + resolve(value.value); }); }); @@ -78,7 +82,11 @@ export const getSteamAppDetails = async ( }; export const getSteamUsersIds = async () => { - const userDataPath = await getSteamLocation(); + const userDataPath = await getSteamLocation().catch(() => null); + + if (!userDataPath) { + return []; + } const userIds = fs.readdirSync(path.join(userDataPath, "userdata"), { withFileTypes: true, diff --git a/src/renderer/src/pages/catalogue/game-item.tsx b/src/renderer/src/pages/catalogue/game-item.tsx index 63748710..ecfe0f73 100644 --- a/src/renderer/src/pages/catalogue/game-item.tsx +++ b/src/renderer/src/pages/catalogue/game-item.tsx @@ -41,7 +41,9 @@ export function GameItem({ game }: GameItemProps) { setAdded(exists); }, [library, game.shop, game.objectId]); - const addGameToLibrary = async (event: React.MouseEvent | React.KeyboardEvent) => { + const addGameToLibrary = async ( + event: React.MouseEvent | React.KeyboardEvent + ) => { event.stopPropagation(); if (added || isAddingToLibrary) return;