fix: using realpath for fedora wine prefix

This commit is contained in:
Chubby Granny Chaser
2025-05-12 17:31:47 +01:00
parent 475ab4119b
commit 1df2353f06
6 changed files with 51 additions and 23 deletions

View File

@@ -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(

View File

@@ -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,
});
};

View File

@@ -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,
});