Comments (6)
Personally, I think I prefer keeping it as nil
, or at least keeping some way of distinguishing between 'we got a type but it's unknown--it is not one of the known types though' and 'we didn't get a type at all--it could be anything, you probably need to do a stat call to find out for sure'.
from luv.
I can confirm that fs_readdir()
shows the same behavior:
function Main()
local luv = require "luv"
local root = "<home>/.local/share/nvim/lazy/vim-snippets/snippets"
local fs = luv.fs_opendir(root, nil, 200)
local data = luv.fs_readdir(fs)
if data then
for _, dirent in ipairs(data) do
print(dirent.type, dirent.name)
end
end
if luv.fs_readdir(fs) then
print("...")
end
luv.fs_closedir(fs)
end
Main()
This prints the same (lengthy) output as the original example.
Explicitly using stat
on the entries that couldn't be read seems to kick the filesystem into doing its job. The following script correctly marks all files as "file"
instead of nil
:
function Main()
local luv = require "luv"
local root = "<home>/.local/share/nvim/lazy/vim-snippets/snippets"
local fs = luv.fs_scandir(root)
local name, type = "", ""
while name do
name, type = luv.fs_scandir_next(fs)
if name and not type then
local stat = luv.fs_stat(root .. "/" .. name)
type = stat.type
end
print(type, name)
end
end
Main()
from luv.
Odd that it works then stops working.
According to https://www.gnu.org/software/libc/manual/html_node/Directory-Entries.html:
The type is unknown. Only some filesystems have full support to return the type of the file, others might always return this value.
On what OS and filesystem do you see this happening?
from luv.
It's odd indeed, it took me a long time to piece together what was happening here.
I access the affected machine remotely, it's managed by our IT department. I'm in contact with them in parallel to figure out if there's something they can do.
$ cat /etc/redhat-release
Rocky Linux release 9.2 (Blue Onyx)
$ mount | grep "/home "
<...> on /home type nfs4 (rw,nosuid,nodev,relatime,vers=4.2,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=<ip addr>,local_lock=none,addr=<ip addr>)
I wonder if the network filesystem and its inevitable lag cause any shenanigans somewhere inside libuv …
from luv.
Surprised that our docs don't mention this; that should definitely be fixed regardless of whether we return nil
or "unknown"
as the type.
I assume the same applies to fs_readdir
but the Libuv docs don't mention it there. Will need to try to test that as well.
from luv.
We can make this return a "unknown" string as well, this is probably the more correct behavior here. I remember reading the code relating this, should be an easy fix, assuming it wasn't intended behavior this shouldn't be a breaking change as well.
from luv.
Related Issues (20)
- `cpu_info` binding might not handle `model` correctly HOT 2
- Release 1.45.0 checklist. HOT 1
- Add `fs_access` test(s)
- request bind v1.46.0 new features
- track issues in neovim related with luv HOT 4
- CI failing for LuaJIT v2.1 branch
- process creation segfault HOT 2
- How to pass command line string to uv.spawn? HOT 4
- Do I have to use `uv.run()` to wait async reading file with `fs_read` API? HOT 2
- Question: Is `shutdown` and `close` (use new_pipe with spawn) sync or async? HOT 1
- Question: the arrival order of uv.spawn `on_exit` and `data == nil` in `read_start` callback on Windows 10? HOT 2
- Why udp_recv_start callback call twice? HOT 2
- `tty normal` normal tests fails for me on Fedora mockbuild HOT 4
- Error loading module luv HOT 3
- Unable to send handles with uv_write2
- UBSan is detecting problems but not failing the CI
- Importance of case for signal names (and other names) HOT 1
- luv_handle_gc segfault (from neovim) HOT 8
- Flaky UDP test in CI HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from luv.