Files
netfelix-audio-fix/server/api/paths.ts
Felix Förtsch da668b2d36
All checks were successful
Build and Push Docker Image / build (push) Successful in 38s
add paths page to check volume accessibility after scan
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 10:31:05 +01:00

36 lines
780 B
TypeScript

import { existsSync } from 'node:fs';
import { Hono } from 'hono';
import { getDb } from '../db/index';
const app = new Hono();
interface PathInfo {
prefix: string;
itemCount: number;
accessible: boolean;
}
app.get('/', (c) => {
const db = getDb();
const rows = db
.query<{ prefix: string; count: number }, []>(
`SELECT substr(file_path, 1, instr(substr(file_path, 2), '/') + 1) AS prefix,
COUNT(*) AS count
FROM media_items
WHERE file_path IS NOT NULL AND file_path != ''
GROUP BY prefix
ORDER BY prefix`,
)
.all();
const paths: PathInfo[] = rows.map((r: { prefix: string; count: number }) => ({
prefix: r.prefix,
itemCount: r.count,
accessible: existsSync(r.prefix),
}));
return c.json({ paths });
});
export default app;