mirror of
https://github.com/pesde-pkg/tooling.git
synced 2025-04-10 22:00:56 +01:00
fix(lib): extracting wrong binary
This commit is contained in:
parent
f3f18089d7
commit
e223c58b2f
1 changed files with 16 additions and 6 deletions
|
@ -44,15 +44,26 @@ local extractBinary: {
|
|||
Zip = function(compressed, binaryName, targetPlatform)
|
||||
local reader = unzip.load(compressed)
|
||||
|
||||
local binaryEntry = reader:findEntry(binaryName)
|
||||
local binaryContents = nil
|
||||
local binaryContents: buffer?
|
||||
|
||||
local function extractEntry(entry: unzip.ZipEntry)
|
||||
local contents = reader:extract(entry, { type = "binary" }) :: buffer
|
||||
local executablePlatform = PlatformDescriptor.fromExecutable(contents)
|
||||
|
||||
if executablePlatform:isOk() and eq(executablePlatform:unwrap(), targetPlatform) then
|
||||
binaryContents = contents
|
||||
end
|
||||
end
|
||||
|
||||
local binaryEntry = reader:findEntry(binaryName)
|
||||
if binaryEntry then
|
||||
binaryContents = reader:extract(binaryEntry, { type = "binary" }) :: buffer
|
||||
else
|
||||
extractEntry(binaryEntry)
|
||||
end
|
||||
|
||||
if not binaryContents then
|
||||
-- Walk through the entries to find an executable
|
||||
reader:walk(function(entry)
|
||||
if binaryEntry then
|
||||
if binaryContents then
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -64,7 +75,6 @@ local extractBinary: {
|
|||
local executablePlatform = PlatformDescriptor.fromExecutable(contents)
|
||||
|
||||
if executablePlatform:isOk() and eq(executablePlatform:unwrap(), targetPlatform) then
|
||||
binaryEntry = entry
|
||||
binaryContents = contents
|
||||
end
|
||||
end)
|
||||
|
|
Loading…
Add table
Reference in a new issue