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:
+6
-2
@@ -266,9 +266,13 @@ router.get('/_config/media/files', async (ctx) => {
|
||||
const scope = ctx.req.query('path') ?? '';
|
||||
try {
|
||||
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));
|
||||
// Prefixed back to the scope, so what comes out is what a gallery item stores.
|
||||
return ctx.json({ files: files.map((file) => (scope ? `${safeScope(scope)}/${file}` : file)) });
|
||||
return ctx.json({ files });
|
||||
} catch (error) {
|
||||
return ctx.json({ error: (error as Error).message }, 400);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user