mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-28 13:21:02 +00:00
fix: using realpath for fedora wine prefix
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { SystemPath } from "@main/services";
|
||||
import { logger, SystemPath } from "@main/services";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { registerEvent } from "../register-event";
|
||||
@@ -6,20 +6,26 @@ import { registerEvent } from "../register-event";
|
||||
const getDefaultWinePrefixSelectionPath = async (
|
||||
_event: Electron.IpcMainInvokeEvent
|
||||
) => {
|
||||
const steamWinePrefixes = path.join(
|
||||
SystemPath.getPath("home"),
|
||||
".local",
|
||||
"share",
|
||||
"Steam",
|
||||
"steamapps",
|
||||
"compatdata"
|
||||
);
|
||||
try {
|
||||
const steamWinePrefixes = path.join(
|
||||
SystemPath.getPath("home"),
|
||||
".local",
|
||||
"share",
|
||||
"Steam",
|
||||
"steamapps",
|
||||
"compatdata"
|
||||
);
|
||||
|
||||
if (fs.existsSync(steamWinePrefixes)) {
|
||||
return steamWinePrefixes;
|
||||
if (fs.existsSync(steamWinePrefixes)) {
|
||||
return fs.promises.realpath(steamWinePrefixes);
|
||||
}
|
||||
|
||||
return null;
|
||||
} catch (err) {
|
||||
logger.error("Failed to get default wine prefix selection path", err);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
registerEvent(
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { registerEvent } from "../register-event";
|
||||
import fs from "node:fs";
|
||||
import { levelKeys, gamesSublevel } from "@main/level";
|
||||
import { Wine } from "@main/services";
|
||||
import type { GameShop } from "@types";
|
||||
@@ -9,19 +10,30 @@ const selectGameWinePrefix = async (
|
||||
objectId: string,
|
||||
winePrefixPath: string | null
|
||||
) => {
|
||||
if (winePrefixPath && !Wine.validatePrefix(winePrefixPath)) {
|
||||
throw new Error("Invalid wine prefix path");
|
||||
}
|
||||
|
||||
const gameKey = levelKeys.game(shop, objectId);
|
||||
|
||||
const game = await gamesSublevel.get(gameKey);
|
||||
|
||||
if (!game) return;
|
||||
|
||||
if (!winePrefixPath) {
|
||||
await gamesSublevel.put(gameKey, {
|
||||
...game,
|
||||
winePrefixPath: null,
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const realWinePrefixPath = await fs.promises.realpath(winePrefixPath);
|
||||
|
||||
if (!Wine.validatePrefix(realWinePrefixPath)) {
|
||||
throw new Error("Invalid wine prefix path");
|
||||
}
|
||||
|
||||
await gamesSublevel.put(gameKey, {
|
||||
...game,
|
||||
winePrefixPath: winePrefixPath,
|
||||
winePrefixPath: realWinePrefixPath,
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -135,10 +135,12 @@ export class CloudSync {
|
||||
shop,
|
||||
objectId,
|
||||
hostname: os.hostname(),
|
||||
winePrefixPath: game?.winePrefixPath ?? null,
|
||||
winePrefixPath: game?.winePrefixPath
|
||||
? fs.realpathSync(game.winePrefixPath)
|
||||
: null,
|
||||
homeDir: this.getWindowsLikeUserProfilePath(game?.winePrefixPath ?? null),
|
||||
downloadOptionTitle,
|
||||
platform: os.platform(),
|
||||
platform: process.platform,
|
||||
label,
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user