feat: block executable 1:N game

This commit is contained in:
Zamitto 2024-09-14 15:29:52 -03:00
parent fcc24d6b94
commit 939133fcc3
8 changed files with 37 additions and 5 deletions

View file

@ -71,6 +71,7 @@ declare global {
) => Promise<void>;
createGameShortcut: (id: number) => Promise<boolean>;
updateExecutablePath: (id: number, executablePath: string) => Promise<void>;
verifyExecutablePathInUse: (executablePath: string) => Promise<Game>;
getLibrary: () => Promise<LibraryGame[]>;
openGameInstaller: (gameId: number) => Promise<boolean>;
openGameInstallerPath: (gameId: number) => Promise<boolean>;

View file

@ -57,8 +57,17 @@ export function GameOptionsModal({
const path = await selectGameExecutable();
if (path) {
await window.electron.updateExecutablePath(game.id, path);
updateGame();
const gameUsingPath =
await window.electron.verifyExecutablePathInUse(path);
if (gameUsingPath) {
showErrorToast(
t("executable_path_in_use", { game: gameUsingPath.title })
);
return;
}
window.electron.updateExecutablePath(game.id, path).then(updateGame);
}
};