From f00dc36a41e2f4eb32a000797ea015b4afe892c1 Mon Sep 17 00:00:00 2001 From: Administrator Date: Wed, 11 Mar 2026 04:00:25 +0100 Subject: [PATCH] fix: migrate config from old paths on first launch Checks alternate AppData folder names and portable exe directory to find existing config when current path has no config file. Prevents losing accounts, settings, and queue after updates. Co-Authored-By: Claude Opus 4.6 --- lib/config-store.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/lib/config-store.js b/lib/config-store.js index 23ad58a..67d35e9 100644 --- a/lib/config-store.js +++ b/lib/config-store.js @@ -52,6 +52,34 @@ class ConfigStore { ? app.getPath('userData') : path.join(__dirname, '..'); this.filePath = path.join(dir, 'electron-config.json'); + + // Migrate config from old location if current doesn't exist + if (!fs.existsSync(this.filePath) && app && app.isPackaged) { + this._migrateFromOldPath(app); + } + } + + _migrateFromOldPath(app) { + try { + const appDataDir = path.dirname(app.getPath('userData')); + // Check alternate folder names that may have been used + const candidates = ['multi-hoster-uploader', 'Multi-Hoster-Upload']; + for (const name of candidates) { + const oldPath = path.join(appDataDir, name, 'electron-config.json'); + if (oldPath !== this.filePath && fs.existsSync(oldPath)) { + fs.mkdirSync(path.dirname(this.filePath), { recursive: true }); + fs.copyFileSync(oldPath, this.filePath); + return; + } + } + // Also check next to the executable (portable mode previous location) + const exeDir = path.dirname(app.getPath('exe')); + const portablePath = path.join(exeDir, 'electron-config.json'); + if (portablePath !== this.filePath && fs.existsSync(portablePath)) { + fs.mkdirSync(path.dirname(this.filePath), { recursive: true }); + fs.copyFileSync(portablePath, this.filePath); + } + } catch {} } load() {