From a9fa6eb6b66ff9ec994c090e0e202ddbbad0f494 Mon Sep 17 00:00:00 2001 From: Haileyesus <118998054+blackmammoth@users.noreply.github.com> Date: Thu, 4 Jun 2026 17:33:58 +0300 Subject: [PATCH] fix(file-tree): inspect entries with lstat Use lstat for file-tree metadata so symlink entries are identified without following targets. --- server/index.js | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/server/index.js b/server/index.js index 6a8dd31d..d857ad4b 100755 --- a/server/index.js +++ b/server/index.js @@ -1564,17 +1564,28 @@ async function getFileTree(dirPath, maxDepth = 3, currentDepth = 0, showHidden = try { await acquire(); try { - const stats = await fsPromises.stat(itemPath); - item.size = stats.size; - item.modified = stats.mtime.toISOString(); + const stats = await fsPromises.lstat(itemPath); + item.size = stats.size; + item.modified = stats.mtime.toISOString(); - // Convert permissions to rwx format - const mode = stats.mode; - const ownerPerm = (mode >> 6) & 7; - const groupPerm = (mode >> 3) & 7; - const otherPerm = mode & 7; - item.permissions = ((mode >> 6) & 7).toString() + ((mode >> 3) & 7).toString() + (mode & 7).toString(); - item.permissionsRwx = permToRwx(ownerPerm) + permToRwx(groupPerm) + permToRwx(otherPerm); + // Mark symlinks so UI can distinguish them + if (stats.isSymbolicLink()) { + item.isSymlink = true; + } + + // Convert permissions to rwx format + const mode = stats.mode; + const ownerPerm = (mode >> 6) & 7; + const groupPerm = (mode >> 3) & 7; + const otherPerm = mode & 7; + item.permissions = + ((mode >> 6) & 7).toString() + + ((mode >> 3) & 7).toString() + + (mode & 7).toString(); + item.permissionsRwx = + permToRwx(ownerPerm) + + permToRwx(groupPerm) + + permToRwx(otherPerm); } finally { release(); }