the expansion route was doubling the folder into every path

`listOriginals` already includes the prefix in what it yields — it builds
`prefix/name` as it descends — so prefixing again produced
Home_Page_Gallery/Home_Page_Gallery/…, a real-looking path to nothing.

Found by calling the route rather than reading it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-29 21:20:27 +01:00
co-authored by Claude Opus 5
parent 6abe5bd337
commit 5cfe571db0
+6 -2
View File
@@ -266,9 +266,13 @@ router.get('/_config/media/files', async (ctx) => {
const scope = ctx.req.query('path') ?? ''; const scope = ctx.req.query('path') ?? '';
try { try {
const root = await originalsDir(user.email); const root = await originalsDir(user.email);
/*
Returned as-is. `listOriginals` already includes the prefix in every path it yields — it builds
`prefix/name` as it descends — so prefixing again produced
`Home_Page_Gallery/Home_Page_Gallery/…`, a real-looking path to nothing.
*/
const files = await listOriginals(root, safeScope(scope)); const files = await listOriginals(root, safeScope(scope));
// Prefixed back to the scope, so what comes out is what a gallery item stores. return ctx.json({ files });
return ctx.json({ files: files.map((file) => (scope ? `${safeScope(scope)}/${file}` : file)) });
} catch (error) { } catch (error) {
return ctx.json({ error: (error as Error).message }, 400); return ctx.json({ error: (error as Error).message }, 400);
} }