fix: use XDG_DOWNLOAD_DIR as default download dir (#2615)

On Linux machines that are using a desktop env which conforms to
the FreeDesktop spec, users should have the XDG_DOWNLOAD_DIR
variable set to specify their default download directory.

This patch ensures that this directory is used if the variable is
present.

Hoping this will fix the following issue in the Mattermost snap:
https://github.com/snapcrafters/mattermost-desktop/issues/65
This commit is contained in:
Jon Seager
2023-03-15 13:12:16 +00:00
committed by GitHub
parent 37e7fb1100
commit 69831bbe13

View File

@@ -19,6 +19,11 @@ export const getDefaultDownloadLocation = (): string | undefined => {
if (__IS_MAC_APP_STORE__) {
return undefined;
}
if (process.platform === 'linux' && process.env.XDG_DOWNLOAD_DIR) {
return process.env.XDG_DOWNLOAD_DIR;
}
return path.join(os.homedir(), 'Downloads');
};