mirror of
https://github.com/H4zeyaf/Breakallery.git
synced 2026-10-17 12:00:46 +02:00
54 lines
1.2 KiB
JavaScript
54 lines
1.2 KiB
JavaScript
const fs = require('fs');
|
|
const path = require('path');
|
|
const { CONFIG_PATH, BASE_DIR, CAPTURES_DIR } = require('./paths');
|
|
|
|
const DEFAULT_CONFIG = {
|
|
ps5: {
|
|
host: '192.168.100.25',
|
|
port: 2121, // default for etaHEN / ftps5 / GoldHEN
|
|
user: 'anonymous',
|
|
password: '',
|
|
timeout: 8000,
|
|
},
|
|
server: {
|
|
port: 5050,
|
|
},
|
|
autoSync: {
|
|
enabled: false,
|
|
intervalMinutes: 10,
|
|
downloadPath: CAPTURES_DIR,
|
|
syncPhotos: true,
|
|
syncVideos: true,
|
|
},
|
|
minimizeToTray: false,
|
|
};
|
|
|
|
function loadConfig() {
|
|
try {
|
|
if (fs.existsSync(CONFIG_PATH)) {
|
|
const data = fs.readFileSync(CONFIG_PATH, 'utf-8');
|
|
return { ...DEFAULT_CONFIG, ...JSON.parse(data) };
|
|
}
|
|
} catch (err) {
|
|
console.error('[Config] Error reading config file, using defaults:', err.message);
|
|
}
|
|
saveConfig(DEFAULT_CONFIG);
|
|
return { ...DEFAULT_CONFIG };
|
|
}
|
|
|
|
function saveConfig(config) {
|
|
try {
|
|
fs.writeFileSync(CONFIG_PATH, JSON.stringify(config, null, 2), 'utf-8');
|
|
return true;
|
|
} catch (err) {
|
|
console.error('[Config] Error saving config file:', err.message);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
loadConfig,
|
|
saveConfig,
|
|
DEFAULT_CONFIG,
|
|
};
|