Retry failed firmware version downloads (#1053)

This commit is contained in:
Tim Wilkinson 2024-01-03 22:32:41 -08:00 committed by GitHub
parent 185d6e0abf
commit 931bc07c0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 24 additions and 18 deletions

View File

@ -274,34 +274,40 @@ if parms.button_refresh_fw then
do do
firmware_versions[k] = v firmware_versions[k] = v
end end
local err = false
local board_type = aredn.hardware.get_board_type():gsub(",", "_") local board_type = aredn.hardware.get_board_type():gsub(",", "_")
for ver, data in pairs(firmware_versions) local firmware_list = {}
for attempt = 1, 3
do do
local raw = io.popen(curl .. " -o - " .. config_serverpath .. data .. "/overview.json 2> /dev/null") for ver, data in pairs(firmware_versions)
local info = luci.jsonc.parse(raw:read("*a") or "") do
raw:close() local raw = io.popen(curl .. " -o - " .. config_serverpath .. data .. "/overview.json 2> /dev/null")
firmware_versions[ver] = nil local info = luci.jsonc.parse(raw:read("*a") or "")
if info then raw:close()
for _, profile in ipairs(info.profiles) if info then
do firmware_versions[ver] = nil
if profile.id == board_type or ((board_type == "qemu-standard-pc-i440fx-piix-1996" or board_type == "VMware, Inc. VMware Virtual Platform") and profile.id == "generic" and profile.target == "x86/64") then for _, profile in ipairs(info.profiles)
firmware_versions[ver] = { do
overview = config_serverpath .. data .. "/" .. profile.target .. "/" .. profile.id .. ".json", if profile.id == board_type or ((board_type == "qemu-standard-pc-i440fx-piix-1996" or board_type == "VMware, Inc. VMware Virtual Platform") and profile.id == "generic" and profile.target == "x86/64") then
target = info.image_url:gsub("{target}", profile.target) firmware_list[ver] = {
} overview = config_serverpath .. data .. "/" .. profile.target .. "/" .. profile.id .. ".json",
break target = info.image_url:gsub("{target}", profile.target)
}
break
end
end end
end end
else
err = true
end end
end end
local f = io.open("/tmp/web/firmware.list", "w") local f = io.open("/tmp/web/firmware.list", "w")
if f then if f then
f:write(luci.jsonc.stringify(firmware_versions, true)) f:write(luci.jsonc.stringify(firmware_list, true))
f:close() f:close()
end end
local err = false
for _, _ in pairs(firmware_versions)
do
err = true
end
if err then if err then
fwout("Failed to load all firmware versions. List is incomplete") fwout("Failed to load all firmware versions. List is incomplete")
else else