mirror of
https://github.com/liamcottle/reticulum-meshchat.git
synced 2026-04-27 16:10:32 +00:00
save .reticulum-meshchat storage dir next to launched exe when using portable version
This commit is contained in:
parent
5a2d5c059a
commit
5aa90ffae4
1 changed files with 16 additions and 4 deletions
|
|
@ -66,6 +66,21 @@ function log(message) {
|
|||
|
||||
}
|
||||
|
||||
function getDefaultStorageDir() {
|
||||
|
||||
// if we are running a windows portable exe, we want to use .reticulum-meshchat in the portable exe dir
|
||||
// e.g if we launch "E:\Some\Path\MeshChat.exe" we want to use "E:\Some\Path\.reticulum-meshchat"
|
||||
const portableExecutableDir = process.env.PORTABLE_EXECUTABLE_DIR;
|
||||
if(process.platform === "win32" && portableExecutableDir != null){
|
||||
return path.join(portableExecutableDir, '.reticulum-meshchat');
|
||||
}
|
||||
|
||||
// otherwise, we will fall back to putting the storage dir in the users home directory
|
||||
// e.g: ~/.reticulum-meshchat
|
||||
return path.join(app.getPath('home'), '.reticulum-meshchat');
|
||||
|
||||
}
|
||||
|
||||
app.whenReady().then(async () => {
|
||||
|
||||
// create browser window
|
||||
|
|
@ -97,9 +112,6 @@ app.whenReady().then(async () => {
|
|||
|
||||
try {
|
||||
|
||||
// determine path for storage
|
||||
const storageDir = path.join(app.getPath('home'), '.reticulum-meshchat'); // ~/.reticulum-meshchat
|
||||
|
||||
// get arguments passed to application, and remove the provided application path
|
||||
const userProvidedArguments = process.argv.slice(1);
|
||||
|
||||
|
|
@ -112,7 +124,7 @@ app.whenReady().then(async () => {
|
|||
|
||||
// if user didn't provide storage dir, we should provide it
|
||||
if(!userProvidedArguments.includes("--storage-dir")){
|
||||
requiredArguments.push("--storage-dir", storageDir);
|
||||
requiredArguments.push("--storage-dir", getDefaultStorageDir());
|
||||
}
|
||||
|
||||
// spawn executable
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue