diff --git a/main.js b/main.js index 14e4663..04245d8 100644 --- a/main.js +++ b/main.js @@ -625,7 +625,14 @@ app.whenReady().then(() => { const launchConfig = configStore.load(); const fm = launchConfig.globalSettings && launchConfig.globalSettings.folderMonitor; if (fm && fm.enabled && fm.folderPath) { - startFolderMonitor(fm); + if (fs.existsSync(fm.folderPath)) { + startFolderMonitor(fm); + } else { + debugLog(`folder-monitor auto-start skipped: path not found (${fm.folderPath})`); + // Persist the disable so the user gets a clean state on next launch + const gs = { ...launchConfig.globalSettings, folderMonitor: { ...fm, enabled: false } }; + configStore.save({ globalSettings: gs }).catch(() => {}); + } } } catch (err) { debugLog(`folder-monitor auto-start failed: ${err.message}`); @@ -1051,11 +1058,27 @@ ipcMain.handle('import-backup', async (_event, legacyPassword) => { const ts = new Date().toISOString().replace(/[:.]/g, '-'); const preImportPath = configStore.filePath.replace('.json', `.pre-import-${ts}.json`); try { fs.copyFileSync(configStore.filePath, preImportPath); } catch {} + // Strip machine-specific state: absolute paths from the source machine will + // not exist on this one (e.g. C:\Users\Administrator\... vs \bakeredwin318\...). + // Any path that does not resolve locally is cleared so the user can re-set it + // instead of hitting silent failures later. + const importedGlobal = imported.globalSettings || {}; + if (importedGlobal.logFilePath && !fs.existsSync(path.dirname(importedGlobal.logFilePath))) { + importedGlobal.logFilePath = ''; + } + if (importedGlobal.folderMonitor && typeof importedGlobal.folderMonitor === 'object') { + const fm = importedGlobal.folderMonitor; + if (fm.folderPath && !fs.existsSync(fm.folderPath)) { + fm.folderPath = ''; + fm.enabled = false; + } + } + importedGlobal.pendingQueue = null; // Single atomic write — no split state, no TOCTOU race const merged = { hosters: imported.hosters, hosterSettings: imported.hosterSettings, - globalSettings: imported.globalSettings, + globalSettings: importedGlobal, history: imported.history || [] }; await configStore._atomicWrite(JSON.stringify(merged, null, 2));