diff --git a/main.js b/main.js index 8155348..2af64b7 100644 --- a/main.js +++ b/main.js @@ -8,6 +8,7 @@ const { processZip } = require('./services/zipProcessor'); const CAD_EXTENSIONS = ['prt', 'asm', 'dwr']; const DEFAULT_DESTINATION = './output/cad'; const SETTINGS_FILENAME = 'cad-router-settings.json'; +const LINUX_RUNTIME_DIR = '.cadroute'; function buildConfig(destination) { const resolvedDestination = String(destination || '').trim() || DEFAULT_DESTINATION; @@ -18,7 +19,19 @@ function buildConfig(destination) { } function getSettingsPath() { - return path.join(app.getPath('userData'), SETTINGS_FILENAME); + return path.join(getRuntimeDirectory(), SETTINGS_FILENAME); +} + +function getRuntimeDirectory() { + if (process.platform === 'linux') { + return path.join(app.getPath('home'), LINUX_RUNTIME_DIR); + } + + return app.getPath('userData'); +} + +async function ensureRuntimeDirectory() { + await fs.ensureDir(getRuntimeDirectory()); } async function loadPersistedDestination() { @@ -59,6 +72,7 @@ function createWindow() { } app.whenReady().then(async () => { + await ensureRuntimeDirectory(); const persistedDestination = await loadPersistedDestination(); config = buildConfig(persistedDestination); createWindow();