Skip to content

Commit b68f3e4

Browse files
committed
NSFS | close stream when getting empty content dir
1 parent 0669471 commit b68f3e4

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/sdk/namespace_fs.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,8 +1021,12 @@ class NamespaceFS {
10211021

10221022
// NOTE: don't move this code after the open
10231023
// this can lead to ENOENT failures due to file not exists when content size is 0
1024-
// if entry is a directory object and its content size = 0 - return empty response
1025-
if (await this._is_empty_directory_content(file_path, fs_context, params)) return null;
1024+
// if entry is a directory object and its content size = 0 - close the stream and return empty response
1025+
if (await this._is_empty_directory_content(file_path, fs_context, params)) {
1026+
res.end();
1027+
await stream_utils.wait_finished(res, { signal: object_sdk.abort_controller.signal });
1028+
return null;
1029+
}
10261030

10271031
file = await nb_native().fs.open(
10281032
fs_context,

0 commit comments

Comments
 (0)