feat(linux): inizializza ~/.cadroute all'avvio
Usa ~/.cadroute come directory runtime/settings su Linux e la crea prima di caricare la destinazione persistita.
This commit is contained in:
16
main.js
16
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();
|
||||
|
||||
Reference in New Issue
Block a user