local http = require("http")
local util = require("util")
function PLUGIN:PreInstall(ctx)
local version = ctx.version
local checksums = {
{ type = "sha512", url = util.CHECKSUM_URL:format(version, "sha512") },
{ type = "sha1", url = util.CHECKSUM_URL:format(version, "sha1") },
}
for _, checksum in ipairs(checksums) do
local resp, err = http.get({
url = checksum.url,
})
if err == nil and resp.status_code == 200 then
local hash = string.match(resp.body, "^(%S+)")
if hash then
local result = {
version = version,
url = util.FILE_URL:format(version),
}
result[checksum.type] = hash
return result
end
end
end
return {
version = version,
url = util.FILE_URL:format(version),
}
end