diff --git a/apps/server/src/utilities/pathUtil.ts b/apps/server/src/utilities/pathUtil.ts index f0877264..fc33c07a 100644 --- a/apps/server/src/utilities/pathUtil.ts +++ b/apps/server/src/utilities/pathUtil.ts @@ -1,27 +1,21 @@ import getPath from 'platform-folders'; import * as path from 'path'; import { Logger } from '@nestjs/common'; -import { homedir } from 'os'; -import { execFileSync } from 'child_process'; export const getSimbridgeDir = () => { try { return path.join(getPath('documents'), 'FlyByWireSim', 'Simbridge'); } catch (e) { - Logger.warn('Could not get documents path via WinAPI, trying alternate method', e); + Logger.warn( + 'Could not get documents path via WinAPI, Windows Controlled Folder Access is likely blocking the app. Using AppData as fallback', + e, + ); } try { - const output = execFileSync('Powershell.exe', ['-Command', `[System.Environment]::GetFolderPath('MyDocuments')`]); - const documents = output.toString().trim(); - if (!documents) { - throw new Error('Path is empty'); - } - return path.join(documents, 'FlyByWireSim', 'Simbridge'); + return path.join(getPath('appdata'), 'FlyByWireSim', 'Simbridge'); } catch (e) { - Logger.warn('Could not get documents path via Powershell, trying to use %USERPROFILE% method', e); + Logger.error('Could not get AppData path via WinAPI. Giving up.', e); } - - return path.join(homedir(), 'Documents', 'FlyByWireSim', 'Simbridge'); }; //@ts-expect-error pkg only defined when running as exe diff --git a/package-lock.json b/package-lock.json index 3333d969..89acd534 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "fbw-simbridge", - "version": "0.6.1", + "version": "0.6.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "fbw-simbridge", - "version": "0.6.1", + "version": "0.6.2", "license": "GPL-3.0-only", "os": [ "win32" diff --git a/package.json b/package.json index 7ad623f6..a3ef8e02 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fbw-simbridge", - "version": "0.6.1", + "version": "0.6.2", "description": "The simbridge server for FBW addons for various tasks the addons themselves can't achieve", "author": "", "private": false,