From e223c58b2f9119d4a347d72f3cc459f3619864eb Mon Sep 17 00:00:00 2001 From: LukaDev <47296785+lukadev-0@users.noreply.github.com> Date: Wed, 15 Jan 2025 21:16:23 +0100 Subject: [PATCH] fix(lib): extracting wrong binary --- toolchainlib/src/compression.luau | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/toolchainlib/src/compression.luau b/toolchainlib/src/compression.luau index d121502..5739eb9 100644 --- a/toolchainlib/src/compression.luau +++ b/toolchainlib/src/compression.luau @@ -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)