diff --git a/src/main/constants.ts b/src/main/constants.ts index ae4703df..0f892af7 100644 --- a/src/main/constants.ts +++ b/src/main/constants.ts @@ -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" : ""}` diff --git a/src/main/events/cloud-save/download-game-artifact.ts b/src/main/events/cloud-save/download-game-artifact.ts index 65e7bf45..99edf3df 100644 --- a/src/main/events/cloud-save/download-game-artifact.ts +++ b/src/main/events/cloud-save/download-game-artifact.ts @@ -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}`);