From 5cfe571db02727cd5f68b7d92562af1903dcdb9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Padez?= Date: Sat, 29 Aug 2026 21:20:27 +0100 Subject: [PATCH] the expansion route was doubling the folder into every path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `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 --- api/router.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/api/router.ts b/api/router.ts index d0e0ef8..d726955 100644 --- a/api/router.ts +++ b/api/router.ts @@ -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); }