Skip to content

Commit

Permalink
ensure "electron-mail" is the default "userData" path
Browse files Browse the repository at this point in the history
* In recent @electron upgrade the default user data dir for some reason got changed the "electron-mail => ElectronMail" way (on Windows platform at least). So the commit gets back used before "electron-mail" value.
  • Loading branch information
vladimiry committed Jul 8, 2021
1 parent 83f63e0 commit 772324b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/electron-main/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
LOCAL_WEBCLIENT_PROTOCOL_PREFIX,
ONE_KB_BYTES,
ONE_MB_BYTES,
PACKAGE_NAME,
RUNTIME_ENV_USER_DATA_DIR,
WEB_PROTOCOL_SCHEME
} from "src/shared/constants";
Expand Down Expand Up @@ -81,18 +82,21 @@ function initLocations(
: "../app",
),
userDataDir: path.resolve(
(() => {
((): string | undefined => {
const envVarName = RUNTIME_ENV_USER_DATA_DIR;
const envVarValue = process.env[envVarName];
if (envVarValue && !directoryExists(envVarValue, storeFs)) {
if (!envVarValue) {
return;
}
if (!directoryExists(envVarValue, storeFs)) {
throw new Error(
`Make sure that the directory exists before passing the "${envVarName}" environment variable`,
);
}
return envVarValue;
})()
||
app.getPath("userData")
??
path.join(app.getPath("appData"), PACKAGE_NAME)
),
}
);
Expand Down

0 comments on commit 772324b

Please sign in to comment.