Refactor file handling to prioritize internal data directories for backups and uploads; enhance error handling and logging for metadata and CSV operations.
Some checks failed
Code Analysis (JS/Vue) / analyze (push) Failing after 47s

This commit is contained in:
Torsten Schulz (local)
2026-02-11 11:42:24 +01:00
parent 0fcf6ced0e
commit 0d533710cd
15 changed files with 225 additions and 127 deletions

View File

@@ -4,13 +4,20 @@ import path from 'path'
export default defineEventHandler(async (event) => {
try {
const cwd = process.cwd()
// In production (.output/server), working dir is .output
// Prefer internal server/data, fallback to public/data
let csvPath
if (cwd.endsWith('.output')) {
csvPath = path.join(cwd, '../public/data/termine.csv')
csvPath = path.join(cwd, '../server/data/termine.csv')
// fallback
if (!(await fs.access(csvPath).then(()=>true).catch(()=>false))) {
csvPath = path.join(cwd, '../public/data/termine.csv')
}
} else {
csvPath = path.join(cwd, 'public/data/termine.csv')
csvPath = path.join(cwd, 'server/data/termine.csv')
if (!(await fs.access(csvPath).then(()=>true).catch(()=>false))) {
csvPath = path.join(cwd, 'public/data/termine.csv')
}
}
const csv = await fs.readFile(csvPath, 'utf-8')