refactor: fix type annotations for adapters

This commit is contained in:
Steven Arcangeli 2023-08-20 17:50:25 +00:00
parent ff62fc28cd
commit 866085407f
7 changed files with 30 additions and 39 deletions

View file

@ -213,19 +213,13 @@ end
---@param url string
---@param column_defs string[]
---@param callback fun(err: nil|string, entries: nil|oil.InternalEntry[])
M.list = function(url, column_defs, callback)
---@param cb fun(err?: string, fetch_more?: fun())
M.list = function(url, column_defs, cb)
local _, path = util.parse_url(url)
assert(path)
local dir = fs.posix_to_os_path(path)
local fetch_meta = columns.get_metadata_fetcher(M, column_defs)
cache.begin_update_url(url)
local function cb(err, data)
if err or not data then
cache.end_update_url(url)
end
callback(err, data)
end
---@diagnostic disable-next-line: param-type-mismatch
uv.fs_opendir(dir, function(open_err, fd)
if open_err then
@ -238,11 +232,7 @@ M.list = function(url, column_defs, callback)
end
end
local read_next
read_next = function(read_err)
if read_err then
cb(read_err)
return
end
read_next = function()
uv.fs_readdir(fd, function(err, entries)
if err then
uv.fs_closedir(fd, function()
@ -254,8 +244,7 @@ M.list = function(url, column_defs, callback)
if inner_err then
cb(inner_err)
else
cb(nil, true)
read_next()
cb(nil, read_next)
end
end)
for _, entry in ipairs(entries) do

View file

@ -206,18 +206,12 @@ end
---@param url string
---@param column_defs string[]
---@param callback fun(err: nil|string, entries: nil|oil.InternalEntry[])
---@param callback fun(err: nil|string, fetch_more?: fun())
M.list = function(url, column_defs, callback)
local res = M.parse_url(url)
cache.begin_update_url(url)
local conn = get_connection(url)
conn:list_dir(url, res.path, function(err, data)
if err or not data then
cache.end_update_url(url)
end
callback(err, data)
end)
conn:list_dir(url, res.path, callback)
end
---@param bufnr integer

View file

@ -124,6 +124,9 @@ end
local dir_meta = {}
---@param url string
---@param path string
---@param callback fun(err: nil|string, fetch_more?: fun())
function SSHFS:list_dir(url, path, callback)
local path_postfix = ""
if path ~= "" then

View file

@ -9,9 +9,9 @@ end
---@param url string
---@param column_defs string[]
---@param cb fun(err: nil|string, entries: nil|oil.InternalEntry[])
---@param cb fun(err?: string, fetch_more?: fun())
M.list = function(url, column_defs, cb)
cb(nil, cache.list_url(url))
cb()
end
---@param name string