feat: create SystemPath class to prevent Hydra not opening when some user folders are not correctly set on windows

This commit is contained in:
Zamitto
2025-04-30 12:10:26 -03:00
parent 6068d70aeb
commit f52f0ca614
11 changed files with 79 additions and 23 deletions

View File

@@ -4,13 +4,13 @@ import * as tar from "tar";
import { registerEvent } from "../register-event";
import axios from "axios";
import os from "node:os";
import { app } from "electron";
import path from "node:path";
import { backupsPath } from "@main/constants";
import type { GameShop } from "@types";
import YAML from "yaml";
import { normalizePath } from "@main/helpers";
import { SystemPath } from "@main/services/system-path";
export interface LudusaviBackup {
files: {
@@ -35,7 +35,7 @@ const replaceLudusaviBackupWithCurrentUser = (
drives: Record<string, string>;
};
const currentHomeDir = normalizePath(app.getPath("home"));
const currentHomeDir = normalizePath(SystemPath.getPath("home"));
/* Renaming logic */
if (os.platform() === "win32") {
@@ -84,7 +84,7 @@ const downloadGameArtifact = async (
homeDir: string;
}>(`/profile/games/artifacts/${gameArtifactId}/download`);
const zipLocation = path.join(app.getPath("userData"), objectKey);
const zipLocation = path.join(SystemPath.getPath("userData"), objectKey);
const backupPath = path.join(backupsPath, `${shop}-${objectId}`);
if (fs.existsSync(backupPath)) {

View File

@@ -5,6 +5,7 @@ import { app } from "electron";
import { removeSymbolsFromName } from "@shared";
import { GameShop } from "@types";
import { gamesSublevel, levelKeys } from "@main/level";
import { SystemPath } from "@main/services/system-path";
const createGameShortcut = async (
_event: Electron.IpcMainInvokeEvent,
@@ -24,7 +25,7 @@ const createGameShortcut = async (
const options = {
filePath,
name: removeSymbolsFromName(game.title),
outputPath: app.getPath("desktop"),
outputPath: SystemPath.getPath("desktop"),
};
return createDesktopShortcut({

View File

@@ -4,9 +4,10 @@ import { app } from "electron";
import path from "path";
import fs from "node:fs";
import { logger } from "@main/services";
import { SystemPath } from "@main/services/system-path";
const windowsStartupPath = path.join(
app.getPath("appData"),
SystemPath.getPath("appData"),
"Microsoft",
"Windows",
"Start Menu",