fix(#2868): windows: do not visit unenumerable directories such as Application Data (#2874)

This commit is contained in:
Alexander Courtis 2024-08-24 13:09:12 +10:00 committed by GitHub
parent ad0b95dee5
commit 210478677c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -35,37 +35,40 @@ local function populate_children(handle, cwd, node, git_status, parent)
end end
local abs = utils.path_join { cwd, name } local abs = utils.path_join { cwd, name }
local profile = log.profile_start("explore populate_children %s", abs)
---@type uv.fs_stat.result|nil if Watcher.is_fs_event_capable(abs) then
local stat = vim.loop.fs_stat(abs) local profile = log.profile_start("explore populate_children %s", abs)
local filter_reason = parent.filters:should_filter_as_reason(abs, stat, filter_status)
if filter_reason == FILTER_REASON.none and not nodes_by_path[abs] and Watcher.is_fs_event_capable(abs) then ---@type uv.fs_stat.result|nil
local child = nil local stat = vim.loop.fs_stat(abs)
if t == "directory" and vim.loop.fs_access(abs, "R") then local filter_reason = parent.filters:should_filter_as_reason(abs, stat, filter_status)
child = builders.folder(node, abs, name, stat) if filter_reason == FILTER_REASON.none and not nodes_by_path[abs] then
elseif t == "file" then local child = nil
child = builders.file(node, abs, name, stat) if t == "directory" and vim.loop.fs_access(abs, "R") then
elseif t == "link" then child = builders.folder(node, abs, name, stat)
local link = builders.link(node, abs, name, stat) elseif t == "file" then
if link.link_to ~= nil then child = builders.file(node, abs, name, stat)
child = link elseif t == "link" then
end local link = builders.link(node, abs, name, stat)
end if link.link_to ~= nil then
if child then child = link
table.insert(node.nodes, child) end
nodes_by_path[child.absolute_path] = true end
explorer_node.update_git_status(child, node_ignored, git_status) if child then
end table.insert(node.nodes, child)
else nodes_by_path[child.absolute_path] = true
for reason, value in pairs(FILTER_REASON) do explorer_node.update_git_status(child, node_ignored, git_status)
if filter_reason == value then end
node.hidden_stats[reason] = node.hidden_stats[reason] + 1 else
for reason, value in pairs(FILTER_REASON) do
if filter_reason == value then
node.hidden_stats[reason] = node.hidden_stats[reason] + 1
end
end end
end end
log.profile_end(profile)
end end
log.profile_end(profile)
end end
end end