From 77622f8c6cf3dd09a2afb798df5e372a9026bf9c Mon Sep 17 00:00:00 2001 From: jisangs Date: Fri, 22 May 2026 16:25:03 +0900 Subject: [PATCH] =?UTF-8?q?=EC=8B=AC=EB=B3=BC=EB=A6=AD=20=EB=A7=81?= =?UTF-8?q?=ED=81=AC=20=ED=8F=B4=EB=8D=94=EB=8F=84=20=ED=91=9C=EC=8B=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/ipc/folder.js | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/src/main/ipc/folder.js b/src/main/ipc/folder.js index 1bf35bf..d50eaee 100644 --- a/src/main/ipc/folder.js +++ b/src/main/ipc/folder.js @@ -46,15 +46,14 @@ function register(mainWindow) { try { const entries = fs.readdirSync(folderPath, { withFileTypes: true }); return entries - .filter(e => e.isDirectory() && !e.name.startsWith('.')) + .filter(e => !e.name.startsWith('.') && isDirectoryEntry(folderPath, e)) .map(e => { const fullPath = path.join(folderPath, e.name); - let hasChildren = false; - try { - hasChildren = fs.readdirSync(fullPath, { withFileTypes: true }) - .some(c => c.isDirectory() && !c.name.startsWith('.')); - } catch {} - return { name: e.name, path: fullPath, hasChildren }; + return { + name: e.name, + path: fullPath, + hasChildren: hasVisibleDirectoryChildren(fullPath), + }; }) .sort((a, b) => a.name.localeCompare(b.name)); } catch { return null; } @@ -90,4 +89,24 @@ function register(mainWindow) { }); } +function isDirectoryEntry(parentPath, entry) { + if (entry.isDirectory()) return true; + if (!entry.isSymbolicLink()) return false; + + try { + return fs.statSync(path.join(parentPath, entry.name)).isDirectory(); + } catch { + return false; + } +} + +function hasVisibleDirectoryChildren(folderPath) { + try { + return fs.readdirSync(folderPath, { withFileTypes: true }) + .some(entry => !entry.name.startsWith('.') && isDirectoryEntry(folderPath, entry)); + } catch { + return false; + } +} + module.exports = { register };