refactor: use job instead of args
This commit is contained in:
@@ -154,11 +154,11 @@ local function setup(st, opts)
|
|||||||
end, opts.order)
|
end, opts.order)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function fetch(self, args)
|
local function fetch(self, job)
|
||||||
-- TODO: remove this once Yazi 0.4 is released
|
-- TODO: remove this once Yazi 0.4 is released
|
||||||
args = args or self
|
job = job or self
|
||||||
|
|
||||||
local cwd = args.files[1].url:parent()
|
local cwd = job.files[1].url:parent()
|
||||||
local repo = root(cwd)
|
local repo = root(cwd)
|
||||||
if not repo then
|
if not repo then
|
||||||
remove(tostring(cwd))
|
remove(tostring(cwd))
|
||||||
@@ -166,7 +166,7 @@ local function fetch(self, args)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local paths = {}
|
local paths = {}
|
||||||
for _, f in ipairs(args.files) do
|
for _, f in ipairs(job.files) do
|
||||||
paths[#paths + 1] = tostring(f.url)
|
paths[#paths + 1] = tostring(f.url)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -192,7 +192,7 @@ local function fetch(self, args)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if args.files[1].cha.is_dir then
|
if job.files[1].cha.is_dir then
|
||||||
ya.dict_merge(changed, bubble_up(changed))
|
ya.dict_merge(changed, bubble_up(changed))
|
||||||
ya.dict_merge(changed, propagate_down(ignored, cwd, Url(repo)))
|
ya.dict_merge(changed, propagate_down(ignored, cwd, Url(repo)))
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -35,12 +35,12 @@ local function setup(st, opts)
|
|||||||
end, 500)
|
end, 500)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function fetch(self, args)
|
local function fetch(self, job)
|
||||||
-- TODO: remove this once Yazi 0.4 is released
|
-- TODO: remove this once Yazi 0.4 is released
|
||||||
args = args or self
|
job = job or self
|
||||||
|
|
||||||
local paths = {}
|
local paths = {}
|
||||||
for _, file in ipairs(args.files) do
|
for _, file in ipairs(job.files) do
|
||||||
paths[#paths + 1] = tostring(file.url)
|
paths[#paths + 1] = tostring(file.url)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1051,17 +1051,17 @@ function M:setup(opts)
|
|||||||
self.fallback_file1 = opts.fallback_file1
|
self.fallback_file1 = opts.fallback_file1
|
||||||
end
|
end
|
||||||
|
|
||||||
function M:fetch(args)
|
function M:fetch(job)
|
||||||
-- TODO: remove this once Yazi 0.4 is released
|
-- TODO: remove this once Yazi 0.4 is released
|
||||||
local not_v4 = not args
|
local not_v4 = not job
|
||||||
args = args or self
|
job = job or self
|
||||||
|
|
||||||
local opts = options()
|
local opts = options()
|
||||||
local merged_files = ya.dict_merge(FILES, opts.with_files or {})
|
local merged_files = ya.dict_merge(FILES, opts.with_files or {})
|
||||||
local merged_exts = ya.dict_merge(EXTS, opts.with_exts or {})
|
local merged_exts = ya.dict_merge(EXTS, opts.with_exts or {})
|
||||||
|
|
||||||
local updates, unknown = {}, {}
|
local updates, unknown = {}, {}
|
||||||
for _, file in ipairs(args.files) do
|
for _, file in ipairs(job.files) do
|
||||||
local mime
|
local mime
|
||||||
if file.cha.len == 0 then
|
if file.cha.len == 0 then
|
||||||
mime = "inode/x-empty"
|
mime = "inode/x-empty"
|
||||||
@@ -1083,8 +1083,8 @@ function M:fetch(args)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if #unknown > 0 then
|
if #unknown > 0 then
|
||||||
args.files = unknown
|
job.files = unknown
|
||||||
return not_v4 and require("mime").fetch(args) or require("mime"):fetch(args)
|
return not_v4 and require("mime").fetch(job) or require("mime"):fetch(job)
|
||||||
end
|
end
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
|
|||||||
Reference in New Issue
Block a user