Skip to content

Commit

Permalink
NSFS | close stream when getting empty content dir
Browse files Browse the repository at this point in the history
  • Loading branch information
nadavMiz committed Feb 19, 2025
1 parent 0669471 commit b68f3e4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/sdk/namespace_fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -1021,8 +1021,12 @@ class NamespaceFS {

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

file = await nb_native().fs.open(
fs_context,
Expand Down

0 comments on commit b68f3e4

Please sign in to comment.