mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-02-03 00:33:49 +03:00
fix: security and persistence adjustments
This commit is contained in:
parent
520eb91a55
commit
e1904b853e
@ -2,10 +2,9 @@ import { gameRepository } from "@main/repository";
|
|||||||
|
|
||||||
import { registerEvent } from "../register-event";
|
import { registerEvent } from "../register-event";
|
||||||
import { shell } from "electron";
|
import { shell } from "electron";
|
||||||
import { exec } from "child_process";
|
import { spawn } from "child_process";
|
||||||
import { parseExecutablePath } from "../helpers/parse-executable-path";
|
import { parseExecutablePath } from "../helpers/parse-executable-path";
|
||||||
import { parseLaunchOptions } from "../helpers/parse-launch-options";
|
import { parseLaunchOptions } from "../helpers/parse-launch-options";
|
||||||
import { logger } from "@main/services";
|
|
||||||
|
|
||||||
const openGame = async (
|
const openGame = async (
|
||||||
_event: Electron.IpcMainInvokeEvent,
|
_event: Electron.IpcMainInvokeEvent,
|
||||||
@ -15,23 +14,15 @@ const openGame = async (
|
|||||||
) => {
|
) => {
|
||||||
const parsedPath = parseExecutablePath(executablePath);
|
const parsedPath = parseExecutablePath(executablePath);
|
||||||
const parsedParams = parseLaunchOptions(launchOptions);
|
const parsedParams = parseLaunchOptions(launchOptions);
|
||||||
const executeCommand = `"${parsedPath}" ${parsedParams}`;
|
|
||||||
|
|
||||||
await gameRepository.update({ id: gameId }, { executablePath: parsedPath });
|
await gameRepository.update({ id: gameId }, { executablePath: parsedPath, launchOptions });
|
||||||
|
|
||||||
if (process.platform === "linux" || process.platform === "darwin") {
|
if (process.platform === "linux" || process.platform === "darwin") {
|
||||||
shell.openPath(parsedPath);
|
shell.openPath(parsedPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (process.platform === "win32") {
|
if (process.platform === "win32") {
|
||||||
exec(executeCommand.trim(), (err) => {
|
spawn(parsedPath, parsedParams, { shell: false });
|
||||||
if (err) {
|
|
||||||
logger.error(
|
|
||||||
`Error opening game #${gameId} with command ${executeCommand}`,
|
|
||||||
err
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ export function GameOptionsModal({
|
|||||||
|
|
||||||
const [showDeleteModal, setShowDeleteModal] = useState(false);
|
const [showDeleteModal, setShowDeleteModal] = useState(false);
|
||||||
const [showRemoveGameModal, setShowRemoveGameModal] = useState(false);
|
const [showRemoveGameModal, setShowRemoveGameModal] = useState(false);
|
||||||
const [launchOptions, setLaunchOptions] = useState("");
|
const [launchOptions, setLaunchOptions] = useState(game.launchOptions ?? "");
|
||||||
|
|
||||||
const {
|
const {
|
||||||
removeGameInstaller,
|
removeGameInstaller,
|
||||||
|
Loading…
Reference in New Issue
Block a user