virtual folders (a node without a source)

Massimo Melina committed Dec 15, 2021 at 12:59 UTC 97a7966fbe1d0b7ab358d454028813e933264413
2 files changed +14 -4
dev-notes.md
+7
@@ -8,6 +8,13 @@
8 - https://www.tutorialspoint.com/koajs/koajs_quick_guide.htm
9
10 # To do
11 +- permissions
12 + R / to see the list
13 + R /folder to see it in the list and access it
14 + you see what you can also get
15 + if permission is denied a 401 warning is displayed with login link
16 + how to trap such clicks? 1) redirect with hash 2) trap click in client and call test api
17 +- search
18 - vfs: serve an html for a folder?
19 - "default" property for vfsNode?
20 - sticky breadcrumbs
src/apis.ts
+7 -4
@@ -29,14 +29,17 @@ export const frontEndApis: ApiHandlers = {
29 if (!node)
30 return
31 const list = await Promise.all((node.children ||[]).map(async (node:VfsNode) =>
32 - node.source && await stat(node.source).then(
33 - statRes => statToFile(node.name, statRes),
34 - () => null) ))
32 + node.source ? await stat(node.source).then(
33 + statRes => statToFile(node.name, statRes),
34 + () => null)
35 + : node.name ? { n: node.name+'/' }
36 + : null
37 + ))
38 _.remove(list, x => !x)
39 let path = node.source
40 if (path) {
41 // using / because trying path.join broke glob() on my Windows machine
39 - path = enforceFinal('/', glob.escapePath(path))
42 + path = enforceFinal('/', glob.escapePath(path.replace(/\\/g,'/')))
43 const res = await glob(path + '*', {
44 stats: true,
45 dot: true,