fix(lib): extracting wrong binary

This commit is contained in:
LukaDev 2025-01-15 21:16:23 +01:00
parent f3f18089d7
commit e223c58b2f

View file

@ -44,15 +44,26 @@ local extractBinary: {
Zip = function(compressed, binaryName, targetPlatform) Zip = function(compressed, binaryName, targetPlatform)
local reader = unzip.load(compressed) local reader = unzip.load(compressed)
local binaryEntry = reader:findEntry(binaryName) local binaryContents: buffer?
local binaryContents = nil
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 if binaryEntry then
binaryContents = reader:extract(binaryEntry, { type = "binary" }) :: buffer extractEntry(binaryEntry)
else end
if not binaryContents then
-- Walk through the entries to find an executable -- Walk through the entries to find an executable
reader:walk(function(entry) reader:walk(function(entry)
if binaryEntry then if binaryContents then
return return
end end
@ -64,7 +75,6 @@ local extractBinary: {
local executablePlatform = PlatformDescriptor.fromExecutable(contents) local executablePlatform = PlatformDescriptor.fromExecutable(contents)
if executablePlatform:isOk() and eq(executablePlatform:unwrap(), targetPlatform) then if executablePlatform:isOk() and eq(executablePlatform:unwrap(), targetPlatform) then
binaryEntry = entry
binaryContents = contents binaryContents = contents
end end
end) end)