Refactor Windows path handling for application data directories
All checks were successful
farmcontrol/farmcontrol-ui/pipeline/head This commit looks good

- Updated multiple files to consistently use `os.homedir()` for constructing the local application data path, improving compatibility and clarity across the codebase.
- This change enhances the reliability of directory retrieval for Windows environments.
This commit is contained in:
Tom Butcher 2026-08-02 22:35:24 +01:00
parent 1fdbb01ceb
commit 2335a64c03
4 changed files with 16 additions and 6 deletions

View File

@ -147,7 +147,9 @@ const isValidMsiPackage = async (filePath) => {
const prepareInstallerPath = async (installerPath) => {
const fileName = path.basename(installerPath)
const updateDir = path.join(
process.env.LOCALAPPDATA || path.join(os.homedir(), 'AppData', 'Local'),
os.homedir(),
'AppData',
'Local',
'FarmControl',
'Updates'
)

View File

@ -19,9 +19,13 @@ const PIPE_RETRY_DELAY_MS = 100
export function getInstanceDir() {
if (process.platform === 'win32') {
const localAppData =
process.env.LOCALAPPDATA || join(os.homedir(), 'AppData', 'Local')
return join(localAppData, 'com.tombutcher.farmcontrol', 'instance')
return join(
os.homedir(),
'AppData',
'Local',
'com.tombutcher.farmcontrol',
'instance'
)
}
return join(process.env.TMPDIR || '/tmp', 'com.tombutcher.farmcontrol', 'instance')

View File

@ -121,7 +121,9 @@ const spawnDetachedMacRestart = ({ appLaunchPath, parentPid }) => {
const spawnDetachedWindowsRestart = ({ appLaunchPath, parentPid }) => {
const updateDir = path.join(
process.env.LOCALAPPDATA || path.join(os.homedir(), 'AppData', 'Local'),
os.homedir(),
'AppData',
'Local',
'FarmControl',
'Updates'
)

View File

@ -147,7 +147,9 @@ const isValidMsiPackage = async (filePath) => {
export const prepareInstallerPath = async (installerPath) => {
const fileName = path.basename(installerPath)
const updateDir = path.join(
process.env.LOCALAPPDATA || path.join(os.homedir(), 'AppData', 'Local'),
os.homedir(),
'AppData',
'Local',
'FarmControl',
'Updates'
)