Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jadeite metadata not checking second link #4

Open
EnergoStalin opened this issue Mar 1, 2024 · 1 comment
Open

jadeite metadata not checking second link #4

EnergoStalin opened this issue Mar 1, 2024 · 1 comment

Comments

@EnergoStalin
Copy link

EnergoStalin commented Mar 1, 2024

Isn't this suppose to check both links and not just error on first one?

for _, uri in pairs(uris) do
if jadeite_metadata ~= nil then
break
end
local response = v1_network_fetch(uri)
if not response["ok"] then
error("Failed to request jadeite metadata (code " .. response["status"] .. "): " .. response["statusText"])
end
jadeite_metadata = response.json()
end

Rip codeberg

local uris = {
"https://codeberg.org/mkrsym1/jadeite/raw/branch/master/metadata.json",
"https://notabug.org/mkrsym1/jadeite-mirror/raw/master/metadata.json"
}

I come up with this
local function get_jadeite_metadata()
  local uris = {
    "https://codeberg.org/mkrsym1/jadeite/raw/branch/master/metadata.json",
    "https://notabug.org/mkrsym1/jadeite-mirror/raw/master/metadata.json"
  }

  local requests = {}
  for _, uri in pairs(uris) do
    local response = v1_network_fetch(uri)
    table.insert(requests, response)

    if response["ok"] then
      jadeite_metadata = response.json()
      break
    end
  end

  if not jadeite_metadata then
    local msg = "Jadeite metadata requests failed:\n"
    for i, r in ipairs(requests) do
      msg = string.format("%s\n%s (code %s): %s" msg, uris[i], r["status"], r["statusText"])
    end

    error(msg)
  end

  return jadeite_metadata
end
@bcrescimanno
Copy link

Regardless of whether it actually checks multiple sources, I'd say the larger issue here is that it results in an application crash which means you can't launch titles that don't depend on jadeite.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants