mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
Refactor to make the plugins can use tar to unzip when needed
* Add spawn_tar function and tar_compatible function
- Create spawn_tar function to run command with tar -xvf to unzip file to tmp
file
* Add os.excute() line to make sure the tmp dir exists because tar
command will not automatically create that dir
* Refactor the logic in the try function to if the zip file can be
unzipped with tar and no password required, use tar, otherwise use
7z
This commit is contained in:
parent
2453539fb5
commit
005dbaa2d4
1 changed files with 11 additions and 0 deletions
|
|
@ -53,6 +53,17 @@ function M:seek(units)
|
|||
end
|
||||
end
|
||||
|
||||
function M:spawn_tar(args)
|
||||
local command = "tar"
|
||||
|
||||
local stdout = args[1] == "l" and Command.PIPED or Command.NULL
|
||||
local child, code = Command(command):args(args):stdout(stdout):stderr(Command.PIPED):spawn()
|
||||
if not child then
|
||||
return nil, "Failed to spawn, error code: " .. tostring(code)
|
||||
end
|
||||
return child, nil
|
||||
end
|
||||
|
||||
function M:spawn_7z(args)
|
||||
local last_error = nil
|
||||
local try = function(name)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue