feat: better error handling
This commit is contained in:
@@ -145,11 +145,11 @@ local function setup(st, opts)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if not change or signs[change] == "" then
|
if not change or signs[change] == "" then
|
||||||
return ui.Line("")
|
return ""
|
||||||
elseif self._file:is_hovered() then
|
elseif self._file:is_hovered() then
|
||||||
return ui.Line { ui.Span(" "), ui.Span(signs[change]) }
|
return ui.Line { " ", signs[change] }
|
||||||
else
|
else
|
||||||
return ui.Line { ui.Span(" "), ui.Span(signs[change]):style(styles[change]) }
|
return ui.Line { " ", ui.Span(signs[change]):style(styles[change]) }
|
||||||
end
|
end
|
||||||
end, opts.order)
|
end, opts.order)
|
||||||
end
|
end
|
||||||
@@ -159,7 +159,10 @@ local function fetch(_, job)
|
|||||||
local repo = root(cwd)
|
local repo = root(cwd)
|
||||||
if not repo then
|
if not repo then
|
||||||
remove(tostring(cwd))
|
remove(tostring(cwd))
|
||||||
return 1
|
if not ya.__250127 then -- TODO: remove this
|
||||||
|
return 1
|
||||||
|
end
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
local paths = {}
|
local paths = {}
|
||||||
@@ -175,8 +178,11 @@ local function fetch(_, job)
|
|||||||
:stdout(Command.PIPED)
|
:stdout(Command.PIPED)
|
||||||
:output()
|
:output()
|
||||||
if not output then
|
if not output then
|
||||||
ya.err("Cannot spawn git command, error: " .. err)
|
if not ya.__250127 then -- TODO: remove this
|
||||||
return 0
|
ya.err("Cannot spawn git command, error: " .. err)
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
return true, Err("Cannot spawn `git` command, error: %s", err)
|
||||||
end
|
end
|
||||||
|
|
||||||
local changed, ignored = {}, {}
|
local changed, ignored = {}, {}
|
||||||
@@ -202,7 +208,10 @@ local function fetch(_, job)
|
|||||||
end
|
end
|
||||||
add(tostring(cwd), repo, changed)
|
add(tostring(cwd), repo, changed)
|
||||||
|
|
||||||
return 3
|
if not ya.__250127 then -- TODO: remove this
|
||||||
|
return 3
|
||||||
|
end
|
||||||
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
return { setup = setup, fetch = fetch }
|
return { setup = setup, fetch = fetch }
|
||||||
|
|||||||
@@ -43,7 +43,11 @@ local function fetch(_, job)
|
|||||||
|
|
||||||
local output, err = Command("tag"):args(paths):stdout(Command.PIPED):output()
|
local output, err = Command("tag"):args(paths):stdout(Command.PIPED):output()
|
||||||
if not output then
|
if not output then
|
||||||
return ya.err("Cannot spawn tag command, error: " .. err)
|
if not ya.__250127 then -- TODO: remove this
|
||||||
|
ya.err("Cannot spawn tag command, error: " .. err)
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
return true, Err("Cannot spawn `tag` command, error: %s", err)
|
||||||
end
|
end
|
||||||
|
|
||||||
local i, tags = 1, {}
|
local i, tags = 1, {}
|
||||||
@@ -61,7 +65,10 @@ local function fetch(_, job)
|
|||||||
end
|
end
|
||||||
|
|
||||||
update(tags)
|
update(tags)
|
||||||
return 1
|
if not ya.__250127 then -- TODO: remove this
|
||||||
|
return 1
|
||||||
|
end
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
local cands = ya.sync(function(st)
|
local cands = ya.sync(function(st)
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ Add this to your `~/.config/yazi/yazi.toml`:
|
|||||||
```toml
|
```toml
|
||||||
[[plugin.prepend_fetchers]]
|
[[plugin.prepend_fetchers]]
|
||||||
id = "mime"
|
id = "mime"
|
||||||
if = "!(mime|dummy)"
|
|
||||||
name = "*"
|
name = "*"
|
||||||
run = "mime-ext"
|
run = "mime-ext"
|
||||||
prio = "high"
|
prio = "high"
|
||||||
|
|||||||
@@ -602,6 +602,7 @@ local EXTS = {
|
|||||||
p7s = "application/pkcs7-signature",
|
p7s = "application/pkcs7-signature",
|
||||||
p8 = "application/pkcs8",
|
p8 = "application/pkcs8",
|
||||||
pas = "text/pascal",
|
pas = "text/pascal",
|
||||||
|
patch = "text/diff",
|
||||||
paw = "application/pawaafile",
|
paw = "application/pawaafile",
|
||||||
pbd = "application/powerbuilder6",
|
pbd = "application/powerbuilder6",
|
||||||
pbm = "image/portable-bitmap",
|
pbm = "image/portable-bitmap",
|
||||||
@@ -1066,6 +1067,10 @@ function M:fetch(job)
|
|||||||
|
|
||||||
local updates, unknown = {}, {}
|
local updates, unknown = {}, {}
|
||||||
for _, file in ipairs(job.files) do
|
for _, file in ipairs(job.files) do
|
||||||
|
if file.cha.is_dummy then
|
||||||
|
goto continue
|
||||||
|
end
|
||||||
|
|
||||||
local mime
|
local mime
|
||||||
if file.cha.len == 0 then
|
if file.cha.len == 0 then
|
||||||
mime = "inode/empty"
|
mime = "inode/empty"
|
||||||
@@ -1081,6 +1086,7 @@ function M:fetch(job)
|
|||||||
else
|
else
|
||||||
updates[tostring(file.url)] = "application/octet-stream"
|
updates[tostring(file.url)] = "application/octet-stream"
|
||||||
end
|
end
|
||||||
|
::continue::
|
||||||
end
|
end
|
||||||
|
|
||||||
if next(updates) then
|
if next(updates) then
|
||||||
@@ -1092,7 +1098,10 @@ function M:fetch(job)
|
|||||||
return require("mime"):fetch(job)
|
return require("mime"):fetch(job)
|
||||||
end
|
end
|
||||||
|
|
||||||
return 1
|
if not ya.__250127 then -- TODO: remove this
|
||||||
|
return 1
|
||||||
|
end
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|||||||
Reference in New Issue
Block a user