diff options
| author | Andrej Mihajlov <and@mullvad.net> | 2018-02-23 15:00:33 +0100 |
|---|---|---|
| committer | Andrej Mihajlov <and@mullvad.net> | 2018-03-05 10:58:50 +0100 |
| commit | c6ea9cd28de4099d2353d34a183bafe38bc95806 (patch) | |
| tree | e6dddbc78f1c7f04b1ccde0bb723f4bcf6a641b7 /app | |
| parent | f556ff313190aece18bb2c0a6a09fb189cdc0cd9 (diff) | |
| download | mullvadvpn-c6ea9cd28de4099d2353d34a183bafe38bc95806.tar.xz mullvadvpn-c6ea9cd28de4099d2353d34a183bafe38bc95806.zip | |
Fix the path to system temp directory on windows
Diffstat (limited to 'app')
| -rw-r--r-- | app/lib/tempdir.js | 21 | ||||
| -rw-r--r-- | app/main.js | 11 |
2 files changed, 24 insertions, 8 deletions
diff --git a/app/lib/tempdir.js b/app/lib/tempdir.js new file mode 100644 index 0000000000..e9f65cd03b --- /dev/null +++ b/app/lib/tempdir.js @@ -0,0 +1,21 @@ +// @flow + +import path from 'path'; + +export function getSystemTemporaryDirectory() { + switch(process.platform) { + case 'win32': { + const windowsPath = process.env.windir; + if(windowsPath) { + return path.join(windowsPath, 'Temp'); + } else { + throw new Error('Missing windir in environment variables.'); + } + } + case 'darwin': + case 'linux': + return '/tmp'; + default: + throw new Error(`Not implemented for ${process.platform}`); + } +} diff --git a/app/main.js b/app/main.js index 3c539dacab..f097521c87 100644 --- a/app/main.js +++ b/app/main.js @@ -10,6 +10,7 @@ import shellescape from 'shell-escape'; import { version } from '../package.json'; import { parseIpcCredentials } from './lib/backend'; import { resolveBin } from './lib/proc'; +import { getSystemTemporaryDirectory } from './lib/tempdir'; import { canTrustRpcAddressFile } from './lib/rpc-file-security'; import { execFile } from 'child_process'; import uuid from 'uuid'; @@ -18,17 +19,11 @@ import type { TrayIconType } from './lib/tray-icon-manager'; const isDevelopment = (process.env.NODE_ENV === 'development'); const isMacOS = (process.platform === 'darwin'); -const isLinux = (process.platform === 'linux'); // The name for application directory used for // scoping logs and user data in platform special folders const appDirectoryName = 'MullvadVPN'; - -const writableDirectory = isMacOS || isLinux - ? '/tmp' - : app.getPath('temp'); - -const rpcAddressFile = path.join(writableDirectory, '.mullvad_rpc_address'); +const rpcAddressFile = path.join(getSystemTemporaryDirectory(), '.mullvad_rpc_address'); let browserWindowReady = false; @@ -115,7 +110,7 @@ const appDelegate = { const logFiles = files.filter(file => file.endsWith('.log')) .map(f => path.join(appDelegate._logFileLocation, f)); - const reportPath = path.join(writableDirectory, uuid.v4() + '.log'); + const reportPath = path.join(app.getPath('temp'), uuid.v4() + '.log'); const binPath = resolveBin('problem-report'); let args = [ |
