-
-
Notifications
You must be signed in to change notification settings - Fork 623
fix(#2794): sshfs compatibility #2922
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
Changes from 2 commits
fe2d3ad
ff1296b
60ded54
f53c40d
bfac4e3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -125,24 +125,27 @@ function Explorer:reload(node, git_status) | |
}) | ||
|
||
while true do | ||
local name, t = vim.loop.fs_scandir_next(handle) | ||
local name, _ = vim.loop.fs_scandir_next(handle) | ||
if not name then | ||
break | ||
end | ||
|
||
local abs = utils.path_join { cwd, name } | ||
---@type uv.fs_stat.result|nil | ||
local stat = vim.loop.fs_stat(abs) | ||
local stat = vim.loop.fs_lstat(abs) | ||
|
||
local filter_reason = self.filters:should_filter_as_reason(abs, stat, filter_status) | ||
if filter_reason == FILTER_REASON.none then | ||
remain_childs[abs] = true | ||
|
||
-- Type must come from fs_stat and not fs_scandir_next to maintain sshfs compatibility | ||
local type = stat and stat.type or nil | ||
|
||
-- Recreate node if type changes. | ||
if nodes_by_path[abs] then | ||
local n = nodes_by_path[abs] | ||
|
||
if n.type ~= t then | ||
if n.type ~= type then | ||
utils.array_remove(node.nodes, n) | ||
explorer_node.node_destroy(n) | ||
nodes_by_path[abs] = nil | ||
|
@@ -151,11 +154,11 @@ function Explorer:reload(node, git_status) | |
|
||
if not nodes_by_path[abs] then | ||
local new_child = nil | ||
if t == "directory" and vim.loop.fs_access(abs, "R") and Watcher.is_fs_event_capable(abs) then | ||
if type == "directory" and vim.loop.fs_access(abs, "R") and Watcher.is_fs_event_capable(abs) then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To avoid any future refactor/rebase fails, and to keep git history simple, please rename |
||
new_child = builders.folder(node, abs, name, stat) | ||
elseif t == "file" then | ||
elseif type == "file" then | ||
new_child = builders.file(node, abs, name, stat) | ||
elseif t == "link" then | ||
elseif type == "link" then | ||
local link = builders.link(node, abs, name, stat) | ||
if link.link_to ~= nil then | ||
new_child = link | ||
|
@@ -238,17 +241,17 @@ function Explorer:refresh_parent_nodes_for_path(path) | |
-- collect parent nodes from the top down | ||
local parent_nodes = {} | ||
NodeIterator.builder({ self }) | ||
:recursor(function(node) | ||
return node.nodes | ||
end) | ||
:applier(function(node) | ||
local abs_contains = node.absolute_path and path:find(node.absolute_path, 1, true) == 1 | ||
local link_contains = node.link_to and path:find(node.link_to, 1, true) == 1 | ||
if abs_contains or link_contains then | ||
table.insert(parent_nodes, node) | ||
end | ||
end) | ||
:iterate() | ||
:recursor(function(node) | ||
return node.nodes | ||
end) | ||
:applier(function(node) | ||
local abs_contains = node.absolute_path and path:find(node.absolute_path, 1, true) == 1 | ||
local link_contains = node.link_to and path:find(node.link_to, 1, true) == 1 | ||
if abs_contains or link_contains then | ||
table.insert(parent_nodes, node) | ||
end | ||
end) | ||
:iterate() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unnecessary whitespace change. You can There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably a result of using |
||
|
||
-- refresh in order; this will expand groups as needed | ||
for _, node in ipairs(parent_nodes) do | ||
|
@@ -351,7 +354,7 @@ function Explorer:populate_children(handle, cwd, node, git_status, parent) | |
}) | ||
|
||
while true do | ||
local name, t = vim.loop.fs_scandir_next(handle) | ||
local name, _ = vim.loop.fs_scandir_next(handle) | ||
if not name then | ||
break | ||
end | ||
|
@@ -362,15 +365,17 @@ function Explorer:populate_children(handle, cwd, node, git_status, parent) | |
local profile = log.profile_start("populate_children %s", abs) | ||
|
||
---@type uv.fs_stat.result|nil | ||
local stat = vim.loop.fs_stat(abs) | ||
local stat = vim.loop.fs_lstat(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] then | ||
-- Type must come from fs_stat and not fs_scandir_next to maintain sshfs compatibility | ||
local type = stat and stat.type or nil | ||
local child = nil | ||
if t == "directory" and vim.loop.fs_access(abs, "R") then | ||
if type == "directory" and vim.loop.fs_access(abs, "R") then | ||
child = builders.folder(node, abs, name, stat) | ||
elseif t == "file" then | ||
elseif type == "file" then | ||
child = builders.file(node, abs, name, stat) | ||
elseif t == "link" then | ||
elseif type == "link" then | ||
local link = builders.link(node, abs, name, stat) | ||
if link.link_to ~= nil then | ||
child = link | ||
|
@@ -434,16 +439,16 @@ end | |
---@param projects table | ||
function Explorer:refresh_nodes(projects) | ||
Iterator.builder({ self }) | ||
:applier(function(n) | ||
if n.nodes then | ||
local toplevel = git.get_toplevel(n.cwd or n.link_to or n.absolute_path) | ||
self:reload(n, projects[toplevel] or {}) | ||
end | ||
end) | ||
:recursor(function(n) | ||
return n.group_next and { n.group_next } or (n.open and n.nodes) | ||
end) | ||
:iterate() | ||
:applier(function(n) | ||
if n.nodes then | ||
local toplevel = git.get_toplevel(n.cwd or n.link_to or n.absolute_path) | ||
self:reload(n, projects[toplevel] or {}) | ||
end | ||
end) | ||
:recursor(function(n) | ||
return n.group_next and { n.group_next } or (n.open and n.nodes) | ||
end) | ||
:iterate() | ||
end | ||
|
||
local event_running = false | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be fs_lstat?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not necessary but we can change for consistency.