local external_data = {
name = "liveupdate_resources5.zip", ---Name for zip archive
path = "./" ---Here we indicate the path to the file. I set root folder
}
local VERSION = 11
---We make requests for data until we receive it
---@param data external_data
---@param index number
---@param attempt number|nil
local function request_data(data, index, attempt)
attempt = attempt or 1
http.request(data.path .. data.name, "GET", function(self, id, response)
if (response.status == 200 or response.status == 304) and response.error == nil and response.response ~= nil then
on_file_received(data, response.response, index)
elseif attempt <= ATTEMPT_COUNT then
---If unsuccessful, I make several attempts to load the data.
attempt = attempt + 1
timer.delay(0.1, false, function()
request_data(data, index, attempt)
end)
else
on_error(data, response.error)
end
end)
end
request_data(external_data, VERSION)