From 87bbad13fa7a0173713c74ab8f128d95994a7214 Mon Sep 17 00:00:00 2001 From: Devin Binnie <52460000+devinbinnie@users.noreply.github.com> Date: Wed, 5 May 2021 12:54:21 -0400 Subject: [PATCH] [MM-35454] Fix default downloads path for Windows and Linux, only set for the app if the path is not blank (#1583) * [MM-35454] Fix default downloads path for Windows and Linux, only set for the app if the path is not blank * Default all other OSes other than Mac/Windows to unix standard --- src/common/config/defaultPreferences.js | 14 +++++++++++++- src/main/main.js | 4 +++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/common/config/defaultPreferences.js b/src/common/config/defaultPreferences.js index ed30a0f3..4b6d0cbd 100644 --- a/src/common/config/defaultPreferences.js +++ b/src/common/config/defaultPreferences.js @@ -6,6 +6,18 @@ * Default user preferences. End-users can change these parameters by editing config.json * @param {number} version - Scheme version. (Not application version) */ + +const getDefaultDownloadLocation = () => { + switch (process.platform) { + case 'darwin': + return `/Users/${process.env.USER || process.env.USERNAME}/Downloads`; + case 'win32': + return `C:\\Users\\${process.env.USER || process.env.USERNAME}\\Downloads`; + default: + return `/home/${process.env.USER || process.env.USERNAME}/Downloads`; + } +}; + const defaultPreferences = { version: 2, teams: [], @@ -23,7 +35,7 @@ const defaultPreferences = { autostart: true, spellCheckerLocale: 'en-US', darkMode: false, - downloadLocation: `/Users/${process.env.USER || process.env.USERNAME}/Downloads`, + downloadLocation: getDefaultDownloadLocation(), }; export default defaultPreferences; diff --git a/src/main/main.js b/src/main/main.js index 481ebd54..d84d67aa 100644 --- a/src/main/main.js +++ b/src/main/main.js @@ -257,7 +257,9 @@ function handleConfigSynchronize() { // TODO: send this to server manager WindowManager.setConfig(config.data); setUnreadBadgeSetting(config.data.showUnreadBadge); - app.setPath('downloads', config.data.downloadLocation); + if (config.data.downloadLocation) { + app.setPath('downloads', config.data.downloadLocation); + } if (app.isReady()) { WindowManager.sendToRenderer(RELOAD_CONFIGURATION); }