fix Analyse

This commit is contained in:
nadja
2026-08-26 16:17:54 +02:00
parent dbd31c6cd0
commit 97e6adefad
7 changed files with 54 additions and 23 deletions

View File

@@ -7,7 +7,12 @@ const DB_FILE = process.env.DB_PATH || join(__dirname, 'data.json');
function loadDB() {
if (existsSync(DB_FILE)) {
return JSON.parse(readFileSync(DB_FILE, 'utf-8'));
try {
return JSON.parse(readFileSync(DB_FILE, 'utf-8'));
} catch (e) {
console.error('DB Datei korrupt, Backup erstellt:', e.message);
try { writeFileSync(DB_FILE + '.bak', readFileSync(DB_FILE, 'utf-8')); } catch {}
}
}
return { users: [], recipes: [], invite_tokens: [], _counters: { users: 0, recipes: 0, invite_tokens: 0 } };
}