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:
DirkFi 2024-08-31 17:13:11 -07:00 committed by sxyazi
parent 2453539fb5
commit 005dbaa2d4
No known key found for this signature in database

View file

@ -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)