From 1b5d1a1234f977fe251ce9cc2234f73822e157fb Mon Sep 17 00:00:00 2001 From: Octopus Date: Fri, 3 Apr 2026 10:07:03 +0800 Subject: [PATCH] fix: handle bare filenames in path-utils.ts isDirectChild --- src/shared/path-utils.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/shared/path-utils.ts b/src/shared/path-utils.ts index ff04fe5c..334845ca 100644 --- a/src/shared/path-utils.ts +++ b/src/shared/path-utils.ts @@ -58,7 +58,12 @@ export function isDirectChild(filePath: string, folderPath: string): boolean { const folderSegments = normFolder.split('/'); const fileSegments = normFile.split('/'); - if (fileSegments.length < 2) return false; // Need at least folder/file + // Handle bare filenames (no directory component, e.g. stored as "dashboard.html"). + // These are root-level files and are a direct child only of the root folder. + // Fixes #1514: bare filenames stored in DB were never matched by any folder query. + if (fileSegments.length < 2) { + return normFolder === '' || normFolder === '.'; + } const fileDir = fileSegments.slice(0, -1).join('/'); // Directory part of file const fileName = fileSegments[fileSegments.length - 1]; // Actual filename