* Revert "revert(#2794): sshfs compatibility (#2920)"
This reverts commit 8405ecfbd6.
Fix for symlinks is simple
* fix sshfs compatibility with symlinks
* add suggestions
* revert variable name change to ease multi-instance feature branch conflicts
---------
Co-authored-by: Alexander Courtis <alex@courtis.org>
This commit is contained in:
@@ -57,13 +57,18 @@ local function remove_dir(cwd)
|
|||||||
end
|
end
|
||||||
|
|
||||||
while true do
|
while true do
|
||||||
local name, t = vim.loop.fs_scandir_next(handle)
|
local name, _ = vim.loop.fs_scandir_next(handle)
|
||||||
if not name then
|
if not name then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
|
||||||
local new_cwd = utils.path_join { cwd, name }
|
local new_cwd = utils.path_join { cwd, name }
|
||||||
if t == "directory" then
|
|
||||||
|
-- Type must come from fs_stat and not fs_scandir_next to maintain sshfs compatibility
|
||||||
|
local stat = vim.loop.fs_stat(new_cwd)
|
||||||
|
local type = stat and stat.type or nil
|
||||||
|
|
||||||
|
if type == "directory" then
|
||||||
local success = remove_dir(new_cwd)
|
local success = remove_dir(new_cwd)
|
||||||
if not success then
|
if not success then
|
||||||
return false
|
return false
|
||||||
|
|||||||
@@ -125,19 +125,22 @@ function Explorer:reload(node, git_status)
|
|||||||
})
|
})
|
||||||
|
|
||||||
while true do
|
while true do
|
||||||
local name, t = vim.loop.fs_scandir_next(handle)
|
local name, _ = vim.loop.fs_scandir_next(handle)
|
||||||
if not name then
|
if not name then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
|
||||||
local abs = utils.path_join { cwd, name }
|
local abs = utils.path_join { cwd, name }
|
||||||
---@type uv.fs_stat.result|nil
|
---@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)
|
local filter_reason = self.filters:should_filter_as_reason(abs, stat, filter_status)
|
||||||
if filter_reason == FILTER_REASON.none then
|
if filter_reason == FILTER_REASON.none then
|
||||||
remain_childs[abs] = true
|
remain_childs[abs] = true
|
||||||
|
|
||||||
|
-- Type must come from fs_stat and not fs_scandir_next to maintain sshfs compatibility
|
||||||
|
local t = stat and stat.type or nil
|
||||||
|
|
||||||
-- Recreate node if type changes.
|
-- Recreate node if type changes.
|
||||||
if nodes_by_path[abs] then
|
if nodes_by_path[abs] then
|
||||||
local n = nodes_by_path[abs]
|
local n = nodes_by_path[abs]
|
||||||
@@ -351,7 +354,7 @@ function Explorer:populate_children(handle, cwd, node, git_status, parent)
|
|||||||
})
|
})
|
||||||
|
|
||||||
while true do
|
while true do
|
||||||
local name, t = vim.loop.fs_scandir_next(handle)
|
local name, _ = vim.loop.fs_scandir_next(handle)
|
||||||
if not name then
|
if not name then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
@@ -362,9 +365,11 @@ function Explorer:populate_children(handle, cwd, node, git_status, parent)
|
|||||||
local profile = log.profile_start("populate_children %s", abs)
|
local profile = log.profile_start("populate_children %s", abs)
|
||||||
|
|
||||||
---@type uv.fs_stat.result|nil
|
---@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)
|
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
|
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 t = stat and stat.type or nil
|
||||||
local child = nil
|
local child = nil
|
||||||
if t == "directory" and vim.loop.fs_access(abs, "R") then
|
if t == "directory" and vim.loop.fs_access(abs, "R") then
|
||||||
child = builders.folder(node, abs, name, stat)
|
child = builders.folder(node, abs, name, stat)
|
||||||
|
|||||||
Reference in New Issue
Block a user