mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-28 05:11:02 +00:00
feat: adding cross cloud save
This commit is contained in:
@@ -7,7 +7,7 @@ import os from "node:os";
|
||||
import type { GameShop, User } from "@types";
|
||||
import { backupsPath } from "@main/constants";
|
||||
import { HydraApi } from "./hydra-api";
|
||||
import { normalizePath } from "@main/helpers";
|
||||
import { normalizePath, parseRegFile } from "@main/helpers";
|
||||
import { logger } from "./logger";
|
||||
import { WindowManager } from "./window-manager";
|
||||
import axios from "axios";
|
||||
@@ -17,6 +17,53 @@ 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"));
|
||||
|
||||
if (process.platform === "linux") {
|
||||
if (!winePrefixPath) {
|
||||
throw new Error("Wine prefix path is required");
|
||||
}
|
||||
|
||||
const userReg = fs.readFileSync(
|
||||
path.join(winePrefixPath, "user.reg"),
|
||||
"utf8"
|
||||
);
|
||||
|
||||
const entries = parseRegFile(userReg);
|
||||
const volatileEnvironment = entries.find(
|
||||
(entry) => entry.path === "Volatile Environment"
|
||||
);
|
||||
|
||||
if (!volatileEnvironment) {
|
||||
throw new Error("Volatile environment not found in user.reg");
|
||||
}
|
||||
|
||||
const { values } = volatileEnvironment;
|
||||
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 {
|
||||
userProfilePath: currentHomeDir,
|
||||
publicProfilePath: path.join("C:", "Users", "Public"),
|
||||
};
|
||||
}
|
||||
|
||||
public static getBackupLabel(automatic: boolean) {
|
||||
const language = i18next.language;
|
||||
|
||||
@@ -102,7 +149,9 @@ export class CloudSync {
|
||||
shop,
|
||||
objectId,
|
||||
hostname: os.hostname(),
|
||||
homeDir: normalizePath(SystemPath.getPath("home")),
|
||||
winePrefixPath: game?.winePrefixPath ?? null,
|
||||
homeDir: this.getProfilePaths(game?.winePrefixPath ?? null)
|
||||
.userProfilePath,
|
||||
downloadOptionTitle,
|
||||
platform: os.platform(),
|
||||
label,
|
||||
|
||||
Reference in New Issue
Block a user