Still having issues with downloading live update files. Sometimes works, sometimes doesn’t.
I tried implementing downloading the entire archive, but having problems as well. After downloading the archive the resource.is_using_liveupdate_data() is not returning true, even after a delay. When I run the game, it downloads the archive, reboots, downloads the archive, reboots and does it a few more time before resource.is_using_liveupdate_data() is finally true.
Is it possible to use the downloaded archive without restarting the game?
Here is my code.
-- This can be anything, but you should keep the platform bundles apart
local ZIP_FILENAME = 'resources.zip'
local APP_SAVE_DIR = 'game_liveupdate'
function init(self)
self.base_url = 'http://localhost:8000/'
print("LiveUpdate Archive Loader: is_using_liveupdate_data:", resource.is_using_liveupdate_data())
end
local function store_archive_cb(self, path, status)
if status == true then
print("Successfully stored live update archive!", path)
--
timer.delay(4, false, function()
if resource.is_using_liveupdate_data() then
msg.post(self.callback_listener, 'liveupdatearchiveloaded')
else
sys.reboot()
end
end)
else
print("Failed to store live update archive, ", path)
-- remove the path
end
end
function on_message(self, message_id, message, sender)
if message_id == hash("attempt_download_archive") then
self.callback_listener = sender
if resource.is_using_liveupdate_data() then
msg.post(self.callback_listener, 'liveupdatearchiveloaded')
else
local url = self.base_url .. ZIP_FILENAME
local path = sys.get_save_file(APP_SAVE_DIR, ZIP_FILENAME)
local options = {
path = path, -- a temporary file on disc. will be removed upon successful liveupdate storage
ignore_cache = true -- we don't want to store a (potentially large) duplicate in our http cache
}
print("Downloading", url)
http.request(url, "GET", function(self, id, response)
if (response.status == 304 or response.status == 200) and not response.error then
-- register the path to the live update system
resource.store_archive(response.path, store_archive_cb)
else
print("Error when downloading", url, "to", path, ":", response.status, response.error)
end
end, nil, nil, options)
end
end
end