mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-27 21:01:02 +00:00
feat: adding wine prefix to backup creation on linux
This commit is contained in:
@@ -23,7 +23,8 @@ const restoreLudusaviBackup = (
|
||||
backupPath: string,
|
||||
title: string,
|
||||
homeDir: string,
|
||||
winePrefixPath?: string | null
|
||||
winePrefixPath?: string | null,
|
||||
artifactWinePrefixPath?: string | null
|
||||
) => {
|
||||
const gameBackupPath = path.join(backupPath, title);
|
||||
const mappingYamlPath = path.join(gameBackupPath, "mapping.yaml");
|
||||
@@ -52,7 +53,7 @@ const restoreLudusaviBackup = (
|
||||
|
||||
const destinationPath = transformLudusaviBackupPathIntoWindowsPath(
|
||||
key,
|
||||
null
|
||||
artifactWinePrefixPath
|
||||
)
|
||||
.replace(homeDir, userProfilePath)
|
||||
.replace("C:/Users/Public", publicProfilePath);
|
||||
@@ -79,10 +80,16 @@ const downloadGameArtifact = async (
|
||||
try {
|
||||
const game = await gamesSublevel.get(levelKeys.game(shop, objectId));
|
||||
|
||||
const { downloadUrl, objectKey, homeDir } = await HydraApi.post<{
|
||||
const {
|
||||
downloadUrl,
|
||||
objectKey,
|
||||
homeDir,
|
||||
winePrefixPath: artifactWinePrefixPath,
|
||||
} = await HydraApi.post<{
|
||||
downloadUrl: string;
|
||||
objectKey: string;
|
||||
homeDir: string;
|
||||
winePrefixPath: string | null;
|
||||
}>(`/profile/games/artifacts/${gameArtifactId}/download`);
|
||||
|
||||
const zipLocation = path.join(SystemPath.getPath("userData"), objectKey);
|
||||
@@ -126,7 +133,8 @@ const downloadGameArtifact = async (
|
||||
backupPath,
|
||||
objectId,
|
||||
normalizePath(homeDir),
|
||||
game?.winePrefixPath
|
||||
game?.winePrefixPath,
|
||||
artifactWinePrefixPath
|
||||
);
|
||||
|
||||
WindowManager.mainWindow?.webContents.send(
|
||||
|
||||
@@ -34,6 +34,7 @@ import "./library/remove-game-from-library";
|
||||
import "./library/select-game-wine-prefix";
|
||||
import "./library/reset-game-achievements";
|
||||
import "./library/toggle-automatic-cloud-sync";
|
||||
import "./library/get-default-wine-prefix-selection-path";
|
||||
import "./misc/open-checkout";
|
||||
import "./misc/open-external";
|
||||
import "./misc/show-open-dialog";
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
import { SystemPath } from "@main/services";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { registerEvent } from "../register-event";
|
||||
|
||||
const getDefaultWinePrefixSelectionPath = async (
|
||||
_event: Electron.IpcMainInvokeEvent
|
||||
) => {
|
||||
const steamWinePrefixes = path.join(
|
||||
SystemPath.getPath("home"),
|
||||
".local",
|
||||
"share",
|
||||
"Steam",
|
||||
"steamapps",
|
||||
"compatdata"
|
||||
);
|
||||
|
||||
if (fs.existsSync(steamWinePrefixes)) {
|
||||
return steamWinePrefixes;
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
registerEvent(
|
||||
"getDefaultWinePrefixSelectionPath",
|
||||
getDefaultWinePrefixSelectionPath
|
||||
);
|
||||
@@ -15,19 +15,25 @@ export class Ludusavi {
|
||||
private static binaryPath = path.join(this.ludusaviPath, "ludusavi");
|
||||
private static configPath = path.join(
|
||||
SystemPath.getPath("userData"),
|
||||
"config.yaml"
|
||||
"ludusavi"
|
||||
);
|
||||
|
||||
public static async getConfig() {
|
||||
const config = YAML.parse(
|
||||
fs.readFileSync(this.configPath, "utf-8")
|
||||
fs.readFileSync(path.join(this.ludusaviPath, "config.yaml"), "utf-8")
|
||||
) as LudusaviConfig;
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
public static async copyConfigFileToUserData() {
|
||||
fs.cpSync(path.join(this.ludusaviPath, "config.yaml"), this.configPath);
|
||||
if (!fs.existsSync(this.configPath)) {
|
||||
fs.mkdirSync(this.configPath, { recursive: true });
|
||||
fs.cpSync(
|
||||
path.join(this.ludusaviPath, "config.yaml"),
|
||||
path.join(this.configPath, "config.yaml")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public static async backupGame(
|
||||
@@ -40,7 +46,7 @@ export class Ludusavi {
|
||||
return new Promise((resolve, reject) => {
|
||||
const args = [
|
||||
"--config",
|
||||
this.ludusaviPath,
|
||||
this.configPath,
|
||||
"backup",
|
||||
objectId,
|
||||
"--api",
|
||||
@@ -106,6 +112,9 @@ export class Ludusavi {
|
||||
|
||||
config.customGames = filteredGames;
|
||||
|
||||
fs.writeFileSync(this.configPath, YAML.stringify(config));
|
||||
fs.writeFileSync(
|
||||
path.join(this.configPath, "config.yaml"),
|
||||
YAML.stringify(config)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user