fix: select client asset archives by version (#1766)

Bug Fixes:
- Improved release archive selection by scoring candidate assets against the client version for more accurate matches.
- Added macOS-archive-path detection to exclude incompatible .app.zip/macos-variant archives from selection.
- Refined the no-match behavior so the system cleanly falls back to the standard zip download when no best archive is available.
This commit is contained in:
Eduardo Dantas 2026-07-18 20:52:38 -03:00 committed by GitHub
parent 8af3aa4bc4
commit 465b7a217e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -69,6 +69,13 @@ local function isLzmaPath(path)
return endsWith(tostring(path or ''):lower(), '.lzma')
end
local function isMacArchivePath(path)
path = tostring(path or ''):lower()
return endsWith(path, '.app.zip') or
path:find('macos', 1, true) or
path:find('%f[%a]mac%f[^%a]')
end
local function isNotFoundError(message)
message = tostring(message or ''):lower()
return message:find('404', 1, true) or message:find('not found', 1, true)
@ -513,24 +520,46 @@ local function normalizeDescriptor(config, version, descriptor)
return descriptor
end
local function findReleaseArchive(release)
local function findReleaseArchive(release, version)
if type(release.assets) ~= 'table' then
return nil
end
local fallback
local tag = tostring(release.tag_name or ''):lower()
local label = version and versionLabel(version):lower() or ''
local bestUrl
local bestScore = 0
for _, asset in ipairs(release.assets) do
local name = tostring(asset.name or ''):lower()
local url = asset.browser_download_url
if url and isArchivePath(name) then
fallback = fallback or url
if not name:find('mac', 1, true) and not name:find('.app.zip', 1, true) then
return url
if url and isArchivePath(name) and not isMacArchivePath(name) then
local score = 0
if tag ~= '' and name:find(tag, 1, true) then
score = score + 4
end
if label ~= '' and name:find(label, 1, true) then
score = score + 2
end
-- Releases may contain unrelated legacy client archives. Only accept
-- an archive that identifies the requested tag or client version.
if score > 0 then
if name:find('client', 1, true) then
score = score + 1
end
if name:find('original', 1, true) or name:find('linux', 1, true) then
score = score - 1
end
if score > bestScore then
bestUrl = url
bestScore = score
end
end
end
end
return fallback
return bestUrl
end
local function codeloadZipUrl(repository, tag)
@ -553,7 +582,7 @@ local function descriptorFromRelease(config, version, release)
manifestUrl = baseUrl .. 'assets.json',
manifestSha256Url = baseUrl .. 'assets.json.sha256',
treeUrl = string.format('https://api.github.com/repos/%s/git/trees/%s?recursive=1', config.repository, tag),
archiveUrl = findReleaseArchive(release) or codeloadZipUrl(config.repository, tag)
archiveUrl = findReleaseArchive(release, version) or codeloadZipUrl(config.repository, tag)
})
end