fix: admin/fs: inaccessible real-folders were displayed as files
Massimo Melina committed
Jan 24, 2024 at 22:59 UTC
eb43582a4d7f04e0fc97eef75699de873de6afe4
1 file changed
+2
-3
src/api.vfs.ts
+2
-3
@@ -9,7 +9,6 @@ import { dirname, extname, join, resolve } from 'path'
9
import { dirStream, enforceFinal, isDirectory, isWindowsDrive, makeMatcher, PERM_KEYS, VfsNodeAdminSend } from './misc'
10
import { IS_WINDOWS, HTTP_BAD_REQUEST, HTTP_NOT_FOUND, HTTP_SERVER_ERROR, HTTP_CONFLICT, HTTP_NOT_ACCEPTABLE } from './const'
11
import { getDrives } from './util-os'
12
-import { Stats } from 'fs'
12
import { getBaseUrlOrDefault, getServerStatus } from './listen'
13
import { promisify } from 'util'
14
import { execFile } from 'child_process'
@@ -30,8 +29,8 @@ const apis: ApiHandlers = {
29
30
async function recur(node=vfs): Promise<VfsNodeAdminSend> {
31
const { source } = node
33
- const stats: false | Stats = Boolean(source) && await stat(source!).catch(() => false)
34
- const isDir = !nodeIsLink(node) && (!source || stats && stats.isDirectory())
32
+ const stats = !source ? undefined : await stat(source!).catch(() => undefined)
33
+ const isDir = !nodeIsLink(node) && (!source || (stats?.isDirectory() ?? node.children?.length! > 0))
34
const copyStats: Pick<VfsNodeAdminSend, 'size' | 'ctime' | 'mtime'> = stats ? _.pick(stats, ['size', 'ctime', 'mtime'])
35
: { size: source ? -1 : undefined }
36
if (copyStats.mtime && Number(copyStats.mtime) === Number(copyStats.ctime))