fix: parent's permissions were overwriting masks' permissions with maskOnly, but only while listing
Massimo Melina committed
Oct 2, 2024 at 23:03 UTC
3a32f48b848ed01eca6a9687c0a39b3d611e228f
2 files changed
+6
-5
src/vfs.ts
+4
-4
@@ -271,7 +271,7 @@ export async function* walkNode(parent: VfsNode, {
271
const name = prefixPath + nodeName
272
took?.add(normalizeFilename(name))
273
const item = { ...child, name }
274
- if (!canSee(item)) continue
274
+ if (!await canSee(item)) continue
275
if (item.source) // real items must be accessible
276
try { await fs.access(item.source) }
277
catch { continue }
@@ -314,7 +314,7 @@ export async function* walkNode(parent: VfsNode, {
314
}
315
if (isFolder) // store it even if we can't see it (masks), as its children can be produced by dirStream
316
parentsCache.set(name, item)
317
- if (canSee(item))
317
+ if (await canSee(item))
318
yield item
319
entry.closingBranch?.then(p =>
320
parentsCache.delete(p || '.'))
@@ -326,9 +326,9 @@ export async function* walkNode(parent: VfsNode, {
326
parentsCache.clear() // hoping for faster GC
327
328
// item will be changed, so be sure to pass a temp node
329
- function canSee(item: VfsNode) {
329
+ async function canSee(item: VfsNode) {
330
// we basename for depth>0 where we already have the rest of the path in the parent's url, and would be duplicated
331
- maskApplier(item, basename(getNodeName(item)))
331
+ await maskApplier(item, basename(getNodeName(item)))
332
inheritFromParent(parent, item)
333
if (ctx && !hasPermission(item, 'can_see', ctx)) return
334
item.isTemp = true
tests/config.yaml
+2
-1
@@ -119,6 +119,7 @@ vfs:
119
can_see: false
120
masks:
121
"*":
122
+ maskOnly: folders
123
can_see: true
124
children:
125
- name: hi
@@ -137,7 +138,7 @@ accounts:
138
disabled: true
139
admins:
140
admin: true
140
-version: 0.54.0-alpha4
141
+version: 0.54.0-alpha4.1
142
max_downloads_per_account: 2
143
max_downloads: 1
144
roots: