diff --git a/main.js b/main.js index 0e49de1..f9627b9 100644 --- a/main.js +++ b/main.js @@ -35,16 +35,8 @@ const { const { initRepo, commitAndPush, getBranches, getCommitLogs } = require('./src/git/gitHandler.js'); // NOTE: credentials/data location is computed via getDataDir() to avoid calling app.getPath before ready -function getDataDir() { - try { - return ppath.join(app.getPath('userData'), 'data'); - } catch (e) { - // Fallback: use __dirname/data (only if app.getPath not available) - return ppath.join(__dirname, 'data'); - } -} function getCredentialsFilePath() { - return ppath.join(getDataDir(), 'credentials.json'); + return ppath.join(app.getPath('userData'), 'credentials.json'); } const ALGORITHM = 'aes-256-cbc'; @@ -188,25 +180,24 @@ ipcMain.handle('select-folder', async () => { ipcMain.handle('select-file', async () => { const result = await dialog.showOpenDialog({ properties: ['openFile', 'multiSelections'] }); if (result.canceled) return { ok: false, files: [] }; - - // Rückgabe mit path und name für jede Datei - const files = result.filePaths.map(filePath => ({ - path: filePath, - name: ppath.basename(filePath) - })); - - return { ok: true, files }; + return { ok: true, files: result.filePaths }; }); ipcMain.handle('save-credentials', async (event, data) => { try { - const DATA_DIR = getDataDir(); const CREDENTIALS_FILE = getCredentialsFilePath(); - ensureDir(DATA_DIR); // robust gegen ENOTDIR + // ✅ Stelle sicher dass das userData Verzeichnis existiert + const userDataDir = app.getPath('userData'); + if (!fs.existsSync(userDataDir)) { + fs.mkdirSync(userDataDir, { recursive: true }); + } + const json = JSON.stringify(data); const cipher = crypto.createCipheriv(ALGORITHM, SECRET_KEY, IV); const encrypted = Buffer.concat([cipher.update(json, 'utf8'), cipher.final()]); fs.writeFileSync(CREDENTIALS_FILE, encrypted); + + console.log('✅ Credentials gespeichert in:', CREDENTIALS_FILE); return { ok: true }; } catch (e) { console.error('save-credentials error', e);