mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
..
This commit is contained in:
parent
e89eb384f6
commit
0dbe509aa1
8 changed files with 19 additions and 19 deletions
|
|
@ -46,12 +46,12 @@ end
|
|||
function M:seek(units) require("code").seek(self, units) end
|
||||
|
||||
function M.spawn_7z(args)
|
||||
local last_error = nil
|
||||
local last_err = nil
|
||||
local try = function(name)
|
||||
local stdout = args[1] == "l" and Command.PIPED or Command.NULL
|
||||
local child, code = Command(name):args(args):stdout(stdout):stderr(Command.PIPED):spawn()
|
||||
local child, err = Command(name):args(args):stdout(stdout):stderr(Command.PIPED):spawn()
|
||||
if not child then
|
||||
last_error = code
|
||||
last_err = err
|
||||
end
|
||||
return child
|
||||
end
|
||||
|
|
@ -64,9 +64,9 @@ function M.spawn_7z(args)
|
|||
end
|
||||
|
||||
if not child then
|
||||
return ya.err("Starting both `7z` and `7zz` failed, error code: " .. tostring(last_error))
|
||||
return ya.err("Starting both `7z` and `7zz` failed, error: " .. last_err)
|
||||
end
|
||||
return child, last_error
|
||||
return child, last_err
|
||||
end
|
||||
|
||||
---List files in an archive
|
||||
|
|
|
|||
|
|
@ -48,9 +48,9 @@ function M:try_with(from, pwd, to)
|
|||
end
|
||||
|
||||
local archive = require("archive")
|
||||
local child, code = archive.spawn_7z { "x", "-aou", "-sccUTF-8", "-p" .. pwd, "-o" .. tostring(tmp), tostring(from) }
|
||||
local child, err = archive.spawn_7z { "x", "-aou", "-sccUTF-8", "-p" .. pwd, "-o" .. tostring(tmp), tostring(from) }
|
||||
if not child then
|
||||
fail("Starting both `7z` and `7zz` failed, error code %s. Do you have 7-zip installed?", code)
|
||||
fail("Starting both `7z` and `7zz` failed, error: " .. err)
|
||||
end
|
||||
|
||||
local output, err = child:wait_with_output()
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ function M:preload()
|
|||
return 1
|
||||
end
|
||||
|
||||
local child, code = Command("magick"):args({
|
||||
local child, err = Command("magick"):args({
|
||||
"-size",
|
||||
"800x560",
|
||||
"-gravity",
|
||||
|
|
@ -40,7 +40,7 @@ function M:preload()
|
|||
}):spawn()
|
||||
|
||||
if not child then
|
||||
ya.err(string.format("Starting `magick` failed with error code %s", code))
|
||||
ya.err("Starting `magick` failed, error: " .. err)
|
||||
return 0
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -10,12 +10,12 @@ local function entry()
|
|||
Command("fzf"):cwd(cwd):stdin(Command.INHERIT):stdout(Command.PIPED):stderr(Command.INHERIT):spawn()
|
||||
|
||||
if not child then
|
||||
return fail("Starting `fzf` failed with error code %s. Do you have it installed?", err)
|
||||
return fail("Starting `fzf` failed, error: " .. err)
|
||||
end
|
||||
|
||||
local output, err = child:wait_with_output()
|
||||
if not output then
|
||||
return fail("Cannot read `fzf` output, error code %s", err)
|
||||
return fail("Cannot read `fzf` output, error: " .. err)
|
||||
elseif not output.status.success and output.status.code ~= 130 then
|
||||
return fail("`fzf` exited with error code %s", output.status.code)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ function M:preload()
|
|||
return 1
|
||||
end
|
||||
|
||||
local child, code = Command("magick"):args({
|
||||
local child, err = Command("magick"):args({
|
||||
"-density",
|
||||
"200",
|
||||
tostring(self.file.url),
|
||||
|
|
@ -33,7 +33,7 @@ function M:preload()
|
|||
}):spawn()
|
||||
|
||||
if not child then
|
||||
ya.err(string.format("Starting `magick` failed with error code %s", code))
|
||||
ya.err("Starting `magick` failed, error: " .. err)
|
||||
return 0
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -16,9 +16,9 @@ function M:fetch(job)
|
|||
end
|
||||
|
||||
local cmd = os.getenv("YAZI_FILE_ONE") or "file"
|
||||
local child, code = Command(cmd):args({ "-bL", "--mime-type", "--" }):args(urls):stdout(Command.PIPED):spawn()
|
||||
local child, err = Command(cmd):args({ "-bL", "--mime-type", "--" }):args(urls):stdout(Command.PIPED):spawn()
|
||||
if not child then
|
||||
ya.err(string.format("Starting `%s` failed with error code %s", cmd, code))
|
||||
ya.err(string.format("Starting `%s` failed, error: %s", cmd, err))
|
||||
return 0
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ function M:preload()
|
|||
local ss = math.floor(meta.format.duration * percent / 100)
|
||||
local qv = 31 - math.floor(PREVIEW.image_quality * 0.3)
|
||||
-- stylua: ignore
|
||||
local child, code = Command("ffmpeg"):args({
|
||||
local child, err = Command("ffmpeg"):args({
|
||||
"-v", "quiet", "-hwaccel", "auto",
|
||||
"-skip_frame", "nokey", "-ss", ss,
|
||||
"-an", "-sn", "-dn",
|
||||
|
|
@ -62,7 +62,7 @@ function M:preload()
|
|||
}):spawn()
|
||||
|
||||
if not child then
|
||||
ya.err("Starting `ffmpeg` failed with error code " .. tostring(code))
|
||||
ya.err("Starting `ffmpeg` failed, error: " .. err)
|
||||
return 0
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -101,12 +101,12 @@ local function entry()
|
|||
:spawn()
|
||||
|
||||
if not child then
|
||||
return fail("Starting `zoxide` failed with error code %s. Do you have it installed?", err)
|
||||
return fail("Starting `zoxide` failed, error: " .. err)
|
||||
end
|
||||
|
||||
local output, err = child:wait_with_output()
|
||||
if not output then
|
||||
return fail("Cannot read `zoxide` output, error code %s", err)
|
||||
return fail("Cannot read `zoxide` output, error: " .. err)
|
||||
elseif not output.status.success and output.status.code ~= 130 then
|
||||
return fail("`zoxide` exited with error code %s", output.status.code)
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue