Improve portable data path resolution logic

Updated getPortableDataPath to prefer storing 'user-data' in Documents/My Games/<AppName>, with a fallback to the app directory if necessary. This enhances data portability and aligns with common user data storage conventions.
This commit is contained in:
2026-01-21 10:23:53 +13:00
parent 6ea31e7f80
commit 48ae196c4c
+15 -3
View File
@@ -85,7 +85,8 @@ class PortableDataManager {
/**
* Get the portable data directory path
* Uses NEBULA_PORTABLE_PATH if set, otherwise creates 'user-data' folder in app directory
* Uses NEBULA_PORTABLE_PATH if set, otherwise creates 'user-data' in Documents/My Games/<AppName>
* with a safe fallback to the app directory.
*/
getPortableDataPath() {
if (this._portableDataPath !== null) {
@@ -110,9 +111,20 @@ class PortableDataManager {
}
}
// Default: create 'user-data' folder in the application directory
// Default: prefer Documents/My Games/<AppName>/user-data
let dataPath = '';
try {
const docsDir = app.getPath('documents');
const appName = app.getName() || 'NebulaBrowser';
dataPath = path.join(docsDir, 'My Games', appName, 'user-data');
} catch (err) {
console.warn('[Portable] Failed to resolve Documents path, using app directory');
}
if (!dataPath) {
const appRoot = this._getAppRootDir();
const dataPath = path.join(appRoot, 'user-data');
dataPath = path.join(appRoot, 'user-data');
}
// Validate the path
if (this._isPathSafe(dataPath)) {