fix: adding path transformation for wine

This commit is contained in:
Chubby Granny Chaser
2025-05-12 12:11:37 +01:00
parent 4ff0132d53
commit 1346ff49a5
2 changed files with 23 additions and 2 deletions

View File

@@ -14,6 +14,8 @@ export const windowsStartMenuPath = path.join(
"Programs"
);
export const publicProfilePath = "C:/Users/Public";
export const levelDatabasePath = path.join(
SystemPath.getPath("userData"),
`hydra-db${isStaging ? "-staging" : ""}`

View File

@@ -4,7 +4,7 @@ import * as tar from "tar";
import { registerEvent } from "../register-event";
import axios from "axios";
import path from "node:path";
import { backupsPath } from "@main/constants";
import { backupsPath, publicProfilePath } from "@main/constants";
import type { GameShop, LudusaviBackupMapping } from "@types";
import YAML from "yaml";
@@ -21,6 +21,17 @@ export const transformLudusaviBackupPathIntoWindowsPath = (
.replace("drive_c", "C:");
};
export const addWinePrefixToWindowsPath = (
windowsPath: string,
winePrefixPath?: string | null
) => {
if (!winePrefixPath) {
return windowsPath;
}
return path.join(winePrefixPath, windowsPath.replace("C:", "drive_c"));
};
const restoreLudusaviBackup = (
backupPath: string,
title: string,
@@ -56,7 +67,15 @@ const restoreLudusaviBackup = (
const destinationPath = transformLudusaviBackupPathIntoWindowsPath(
key,
artifactWinePrefixPath
).replace(homeDir, userProfilePath);
)
.replace(
homeDir,
addWinePrefixToWindowsPath(userProfilePath, winePrefixPath)
)
.replace(
publicProfilePath,
addWinePrefixToWindowsPath(publicProfilePath, winePrefixPath)
);
logger.info(`Moving ${sourcePath} to ${destinationPath}`);