Skip to content

Commit

Permalink
save .reticulum config dir next to launched exe when using portable v…
Browse files Browse the repository at this point in the history
…ersion
  • Loading branch information
liamcottle committed Dec 16, 2024
1 parent 5aa90ff commit 3264e63
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions electron/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,21 @@ function getDefaultStorageDir() {

}

function getDefaultReticulumConfigDir() {

// if we are running a windows portable exe, we want to use .reticulum in the portable exe dir
// e.g if we launch "E:\Some\Path\MeshChat.exe" we want to use "E:\Some\Path\.reticulum"
const portableExecutableDir = process.env.PORTABLE_EXECUTABLE_DIR;
if(process.platform === "win32" && portableExecutableDir != null){
return path.join(portableExecutableDir, '.reticulum');
}

// otherwise, we will fall back to using the .reticulum folder in the users home directory
// e.g: ~/.reticulum
return path.join(app.getPath('home'), '.reticulum');

}

app.whenReady().then(async () => {

// create browser window
Expand Down Expand Up @@ -122,6 +137,11 @@ app.whenReady().then(async () => {
// '--test-exception-message', 'Test Exception Message', // uncomment to test the crash dialog
];

// if user didn't provide reticulum config dir, we should provide it
if(!userProvidedArguments.includes("--reticulum-config-dir")){
requiredArguments.push("--reticulum-config-dir", getDefaultReticulumConfigDir());
}

// if user didn't provide storage dir, we should provide it
if(!userProvidedArguments.includes("--storage-dir")){
requiredArguments.push("--storage-dir", getDefaultStorageDir());
Expand Down

0 comments on commit 3264e63

Please sign in to comment.