From 48ae196c4c5306d431c74ae7adbccd82a5835d86 Mon Sep 17 00:00:00 2001 From: Andrew Zambazos Date: Wed, 21 Jan 2026 10:23:53 +1300 Subject: [PATCH] Improve portable data path resolution logic Updated getPortableDataPath to prefer storing 'user-data' in Documents/My Games/, with a fallback to the app directory if necessary. This enhances data portability and aligns with common user data storage conventions. --- portable-data.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/portable-data.js b/portable-data.js index 2bfa7ac..fe2e967 100644 --- a/portable-data.js +++ b/portable-data.js @@ -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/ + * 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 - const appRoot = this._getAppRootDir(); - const dataPath = path.join(appRoot, 'user-data'); + // Default: prefer Documents/My Games//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(); + dataPath = path.join(appRoot, 'user-data'); + } // Validate the path if (this._isPathSafe(dataPath)) {