mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-11 13:56:16 +00:00
fix: fixing home dir mapping
This commit is contained in:
@@ -8,7 +8,7 @@ import { backupsPath } from "@main/constants";
|
||||
import type { GameShop, LudusaviBackupMapping } from "@types";
|
||||
|
||||
import YAML from "yaml";
|
||||
import { normalizePath } from "@main/helpers";
|
||||
import { addTrailingSlash, normalizePath } from "@main/helpers";
|
||||
import { SystemPath } from "@main/services/system-path";
|
||||
import { gamesSublevel, levelKeys } from "@main/level";
|
||||
|
||||
@@ -16,7 +16,9 @@ export const transformLudusaviBackupPathIntoWindowsPath = (
|
||||
backupPath: string,
|
||||
winePrefixPath?: string | null
|
||||
) => {
|
||||
return backupPath.replace(winePrefixPath ?? "", "").replace("drive_c", "C:");
|
||||
return backupPath
|
||||
.replace(winePrefixPath ? addTrailingSlash(winePrefixPath) : "", "")
|
||||
.replace("drive_c", "C:");
|
||||
};
|
||||
|
||||
const restoreLudusaviBackup = (
|
||||
@@ -35,8 +37,8 @@ const restoreLudusaviBackup = (
|
||||
drives: Record<string, string>;
|
||||
};
|
||||
|
||||
const { userProfilePath, publicProfilePath } =
|
||||
CloudSync.getProfilePaths(winePrefixPath);
|
||||
const userProfilePath =
|
||||
CloudSync.getWindowsLikeUserProfilePath(winePrefixPath);
|
||||
|
||||
manifest.backups.forEach((backup) => {
|
||||
Object.keys(backup.files).forEach((key) => {
|
||||
@@ -54,9 +56,7 @@ const restoreLudusaviBackup = (
|
||||
const destinationPath = transformLudusaviBackupPathIntoWindowsPath(
|
||||
key,
|
||||
artifactWinePrefixPath
|
||||
)
|
||||
.replace(homeDir, userProfilePath)
|
||||
.replace("C:/Users/Public", publicProfilePath);
|
||||
).replace(homeDir, userProfilePath);
|
||||
|
||||
logger.info(`Moving ${sourcePath} to ${destinationPath}`);
|
||||
|
||||
|
||||
@@ -33,4 +33,7 @@ export const isPortableVersion = () => {
|
||||
export const normalizePath = (str: string) =>
|
||||
path.posix.normalize(str).replace(/\\/g, "/");
|
||||
|
||||
export const addTrailingSlash = (str: string) =>
|
||||
str.endsWith("/") ? str : `${str}/`;
|
||||
|
||||
export * from "./reg-parser";
|
||||
|
||||
@@ -17,9 +17,7 @@ import i18next, { t } from "i18next";
|
||||
import { SystemPath } from "./system-path";
|
||||
|
||||
export class CloudSync {
|
||||
public static getProfilePaths(winePrefixPath?: string | null) {
|
||||
const currentHomeDir = normalizePath(SystemPath.getPath("home"));
|
||||
|
||||
public static getWindowsLikeUserProfilePath(winePrefixPath?: string | null) {
|
||||
if (process.platform === "linux") {
|
||||
if (!winePrefixPath) {
|
||||
throw new Error("Wine prefix path is required");
|
||||
@@ -43,25 +41,13 @@ export class CloudSync {
|
||||
const userProfile = String(values["USERPROFILE"]);
|
||||
|
||||
if (userProfile) {
|
||||
return {
|
||||
userProfilePath: path.join(
|
||||
winePrefixPath,
|
||||
normalizePath(userProfile.replace("C:", "drive_c"))
|
||||
),
|
||||
publicProfilePath: path.join(
|
||||
winePrefixPath,
|
||||
"drive_c",
|
||||
"users",
|
||||
"Public"
|
||||
),
|
||||
};
|
||||
return normalizePath(userProfile.replace("C:", "drive_c"));
|
||||
} else {
|
||||
throw new Error("User profile not found in user.reg");
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
userProfilePath: currentHomeDir,
|
||||
publicProfilePath: path.join("C:", "Users", "Public"),
|
||||
};
|
||||
return normalizePath(SystemPath.getPath("home"));
|
||||
}
|
||||
|
||||
public static getBackupLabel(automatic: boolean) {
|
||||
@@ -150,8 +136,7 @@ export class CloudSync {
|
||||
objectId,
|
||||
hostname: os.hostname(),
|
||||
winePrefixPath: game?.winePrefixPath ?? null,
|
||||
homeDir: this.getProfilePaths(game?.winePrefixPath ?? null)
|
||||
.userProfilePath,
|
||||
homeDir: this.getWindowsLikeUserProfilePath(game?.winePrefixPath ?? null),
|
||||
downloadOptionTitle,
|
||||
platform: os.platform(),
|
||||
label,
|
||||
|
||||
Reference in New Issue
Block a user