| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent ce93b8b commit 4619fe0
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -143,7 +143,7 @@ class Cache { | |||
| 143 | 143 | if (cached) { | |
| 144 | 144 | return cached; | |
| 145 | 145 | } | |
| 146 | - const promise = PromisePrototypeThen(readdir(path, { __proto__: null, withFileTypes: true }), null, () => null); | ||
| 146 | + const promise = PromisePrototypeThen(readdir(path, { __proto__: null, withFileTypes: true }), null, () => []); | ||
| 147 | 147 | this.#readdirCache.set(path, promise); | |
| 148 | 148 | return promise; | |
| 149 | 149 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,7 +2,7 @@ import * as common from '../common/index.mjs'; | |||
| 2 | 2 | import tmpdir from '../common/tmpdir.js'; | |
| 3 | 3 | import { resolve, dirname, sep, relative, join, isAbsolute } from 'node:path'; | |
| 4 | 4 | import { mkdir, writeFile, symlink, glob as asyncGlob } from 'node:fs/promises'; | |
| 5 | - import { glob, globSync, Dirent } from 'node:fs'; | ||
| 5 | + import { glob, globSync, Dirent, chmodSync } from 'node:fs'; | ||
| 6 | 6 | import { test, describe } from 'node:test'; | |
| 7 | 7 | import { pathToFileURL } from 'node:url'; | |
| 8 | 8 | import { promisify } from 'node:util'; | |
@@ -518,3 +518,24 @@ describe('fsPromises glob - exclude', function() { | |||
| 518 | 518 | }); | |
| 519 | 519 | } | |
| 520 | 520 | }); | |
| 521 | + | ||
| 522 | + describe('glob - with restricted directory', function() { | ||
| 523 | + test('*', async () => { | ||
| 524 | + const restrictedDir = tmpdir.resolve('restricted'); | ||
| 525 | + await mkdir(restrictedDir, { recursive: true }); | ||
| 526 | + chmodSync(restrictedDir, 0o000); | ||
| 527 | + try { | ||
| 528 | + const results = []; | ||
| 529 | + for await (const match of asyncGlob('*', { cwd: restrictedDir })) { | ||
| 530 | + results.push(match); | ||
| 531 | + } | ||
| 532 | + assert.ok(true, 'glob completed without throwing on readdir error'); | ||
| 533 | + } finally { | ||
| 534 | + try { | ||
| 535 | + chmodSync(restrictedDir, 0o755); | ||
| 536 | + } catch { | ||
| 537 | + // ignore | ||
| 538 | + } | ||
| 539 | + } | ||
| 540 | + }); | ||
| 541 | + }); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments