diff options
| -rw-r--r-- | app/main.js | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/app/main.js b/app/main.js index 31880248ae..5b242a644c 100644 --- a/app/main.js +++ b/app/main.js @@ -26,6 +26,7 @@ const ApplicationMain = { return; } + this._overrideAppPaths(); this._initLogging(); log.info(`Running version ${app.getVersion()}`); @@ -53,6 +54,20 @@ const ApplicationMain = { return shouldQuit; }, + _overrideAppPaths() { + // This ensures that on Windows the %LOCALAPPDATA% directory is used instead of the %ADDDATA% + // directory that has roaming contents + if (process.platform == 'win32') { + const appDataDir = process.env.LOCALAPPDATA; + if (appDataDir) { + app.setPath('appData', appDataDir); + app.setPath('userData', path.join(appDataDir, app.getName())); + } else { + throw new Error('Missing %LOCALAPPDATA% environment variable'); + } + } + }, + _initLogging() { const logDirectory = this._getLogsDirectory(); const format = '[{y}-{m}-{d} {h}:{i}:{s}.{ms}][{level}] {text}'; @@ -98,7 +113,7 @@ const ApplicationMain = { // macOS: ~/Library/Logs/{appname} return path.join(app.getPath('home'), 'Library/Logs', app.getName()); default: - // Windows: %APPDATA%\{appname}\logs + // Windows: %LOCALAPPDATA%\{appname}\logs // Linux: ~/.config/{appname}/logs return path.join(app.getPath('userData'), 'logs'); } |
