Revert "node:fs.readdir: should not fail even if folder contains self-referential symlinks" (#10750)

This commit is contained in:
Meghan Denny
2024-05-01 14:59:01 -07:00
committed by GitHub
parent bd632464a0
commit 23e4f609bf
3 changed files with 0 additions and 27 deletions

View File

@@ -504,12 +504,6 @@ pub const AsyncReaddirRecursiveTask = struct {
is_root,
)) {
.err => |err| {
// readdir() should never fail with 'ELOOP: Too many levels of symbolic links'
if (err.getErrno() == .LOOP) {
this.writeResults(ResultType, &entries);
return;
}
for (entries.items) |*item| {
switch (ResultType) {
bun.String => item.deref(),
@@ -4973,8 +4967,6 @@ pub const NodeFS = struct {
// This is different than what Node does, at the time of writing.
// Node doesn't gracefully handle errors like these. It fails the entire operation.
.NOENT, .NOTDIR, .PERM => continue,
// readdir() should never fail with 'ELOOP: Too many levels of symbolic links'
.LOOP => continue,
else => {
const path_parts = [_]string{ args.path.slice(), basename };
return .{

View File

@@ -1 +0,0 @@
../../../..

View File

@@ -8,7 +8,6 @@ import fs, {
existsSync,
mkdirSync,
openSync,
readdir,
readdirSync,
readFile,
readFileSync,
@@ -3031,20 +3030,3 @@ it("promises.fdatasync with a bad fd should include that in the error thrown", a
}
expect.unreachable();
});
it("readdirSync should not crash on symlink loops", () => {
// prettier-ignore
expect(readdirSync(join(import.meta.dirname, "./fixtures/readdir-loop"), { recursive: true }).length).toBe(symlink_fixture_depth());
});
it("readdir should not crash on symlink loops", async () => {
// prettier-ignore
expect((await promisify(readdir)(join(import.meta.dirname, "./fixtures/readdir-loop"), { recursive: true })).length).toBe(symlink_fixture_depth());
});
function symlink_fixture_depth() {
if (process.platform === "darwin") return 166;
if (process.platform === "linux") return 206;
if (process.platform === "win32") return 6;
throw new Error(`test unimplemented for '${process.platform}'`);
}