Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: catch undocumented edge case in scandir() #966

Merged
merged 2 commits into from
Jul 26, 2023

Conversation

troiganto
Copy link
Contributor

While libuv/vim.loop docs say that fs_scandir_next() either returns nil or string, string or fails, there is an edge case on networked filesystems. In those cases, uv__fs_scandir() returns the type UV_DIRENT_UNKNOWN and luv.fs_scandir_next() converts this into returning a single string.

This means in those cases, name is a string and type is nil. See the upstream bug report.

The situation can be remedied by explicitly calling fs_stat() on those files. This always fetches the correct type, as far as I can see.

PS: Thanks for this awesome plugin! 🙂

Nico Madysa and others added 2 commits July 26, 2023 16:07
While libuv/vim.loop docs say that `fs_scandir_next()` either returns
`nil` or `string, string` or fails, there is an edge case on networked
filesystems. In those cases, `uv__fs_scandir()` returns the type
`UV_DIRENT_UNKNOWN` and `luv.fs_scandir_next()` [converts][1] this into
returning a single string.

This means in those cases, `name` is a string and `type` is `nil`. See
[this bug report][2].

The situation can be remedied by explicitly calling `fs_stat()` on those
files. This always fetches the correct type, as far as I can see.

[1]: https://github.com/luvit/luv/blob/master/src/fs.c#L116
[2]: luvit/luv#660
@L3MON4D3
Copy link
Owner

Damn, that's a clean PR👌👌👌👌
Thank you very much!!

@L3MON4D3 L3MON4D3 merged commit e81cbe6 into L3MON4D3:master Jul 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants