From d9adc49e9fb7ed525a5c5129f3cf4ee08fb708ab Mon Sep 17 00:00:00 2001 From: JackEnx <167036558+JackEnx@users.noreply.github.com> Date: Mon, 16 Dec 2024 16:53:09 -0300 Subject: [PATCH] fix: executable slice --- src/main/services/process-watcher.ts | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/main/services/process-watcher.ts b/src/main/services/process-watcher.ts index fda22a56..b9c26e42 100644 --- a/src/main/services/process-watcher.ts +++ b/src/main/services/process-watcher.ts @@ -59,7 +59,7 @@ const findGamePathByProcess = ( ); for (const executable of executables) { - const exe = getExecutable(executable.name); + const exe = executable.name.slice(executable.name.lastIndexOf("/")); if (!exe) continue; @@ -98,12 +98,6 @@ const getSystemProcessMap = async () => { return map; }; -const getExecutable = (path: string) => { - return path.slice( - path.lastIndexOf(process.platform === "win32" ? "\\" : "/") + 1 - ); -}; - export const watchProcesses = async () => { const gameIds = await gamesIdWithoutPath(); @@ -123,11 +117,15 @@ export const watchProcesses = async () => { if (!games.length) return; for (const game of games) { - if (!game.executablePath) continue; + const executablePath = game.executablePath; - const executable = getExecutable(game.executablePath); + if (!executablePath) continue; - const gameProcess = processMap.get(executable)?.has(game.executablePath); + const executable = executablePath.slice( + executablePath.lastIndexOf(process.platform === "win32" ? "\\" : "/") + 1 + ); + + const gameProcess = processMap.get(executable)?.has(executablePath); if (gameProcess) { if (gamesPlaytime.has(game.id)) {