Skip to content

Commit 11cedfe

Browse files
committed
Read all results for subdirectories in opendir
Fixes #48820
1 parent b361ad7 commit 11cedfe

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

lib/internal/fs/dir.js

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -166,18 +166,22 @@ class Dir {
166166
pathModule.toNamespacedPath(dirent.path),
167167
this[kDirOptions].encoding,
168168
undefined,
169-
ctx,
169+
ctx
170170
);
171171
handleErrorFromBinding(ctx);
172-
const result = handle.read(
173-
this[kDirOptions].encoding,
174-
this[kDirOptions].bufferSize,
175-
undefined,
176-
ctx,
177-
);
172+
while (true) {
173+
const result = handle.read(
174+
this[kDirOptions].encoding,
175+
this[kDirOptions].bufferSize,
176+
undefined,
177+
ctx,
178+
);
178179

179-
if (result) {
180-
this.processReadResult(dirent.path, result);
180+
if (result) {
181+
this.processReadResult(dirent.path, result);
182+
} else {
183+
break;
184+
}
181185
}
182186

183187
handle.close(undefined, ctx);
@@ -206,7 +210,7 @@ class Dir {
206210
this[kDirOptions].encoding,
207211
this[kDirOptions].bufferSize,
208212
undefined,
209-
ctx,
213+
ctx
210214
);
211215
handleErrorFromBinding(ctx);
212216

0 commit comments

Comments
 (0)