fix: stat files if fs_readdir doesn't provide a type (#543)
This commit is contained in:
parent
1f7da07a3e
commit
c6a39a69b2
1 changed files with 7 additions and 0 deletions
|
|
@ -301,6 +301,12 @@ local function fetch_entry_metadata(parent_dir, entry, require_stat, cb)
|
||||||
entry[FIELD_META] = meta
|
entry[FIELD_META] = meta
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Sometimes fs_readdir entries don't have a type, so we need to stat them.
|
||||||
|
-- See https://github.com/stevearc/oil.nvim/issues/543
|
||||||
|
if not require_stat and not entry[FIELD_TYPE] then
|
||||||
|
require_stat = true
|
||||||
|
end
|
||||||
|
|
||||||
-- Make sure we always get fs_stat info for links
|
-- Make sure we always get fs_stat info for links
|
||||||
if entry[FIELD_TYPE] == "link" then
|
if entry[FIELD_TYPE] == "link" then
|
||||||
read_link_data(entry_path, function(link_err, link, link_stat)
|
read_link_data(entry_path, function(link_err, link, link_stat)
|
||||||
|
|
@ -332,6 +338,7 @@ local function fetch_entry_metadata(parent_dir, entry, require_stat, cb)
|
||||||
return cb(stat_err)
|
return cb(stat_err)
|
||||||
end
|
end
|
||||||
assert(stat)
|
assert(stat)
|
||||||
|
entry[FIELD_TYPE] = stat.type
|
||||||
meta.stat = stat
|
meta.stat = stat
|
||||||
cb()
|
cb()
|
||||||
end)
|
end)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue