Live Update: Delete resource


Continuing on the Live Update suggestions streak, a mechanism for identifying and deleting unused resources left over by a previous version of the game would be nice. As it is now, with often enough patches and content updates it seems like resources stored with store_resource() would just pile up and use disk space on the player’s device indefinitely.

I’m really unsure how this would work. I don’t know if live update content is included in the manifest or not (I assume so), but maybe something like:

local table_of_resource_hashes = resource.list_resources_in_manifest(manifest_ref)
local table_of_resource_hashes  = resource.list_stored_resources()

Could not publish LiveUpdate content to AWS

We should be able to detect this when updating the manifest. Any downloaded and stored resource that isn’t part of the new manifest should automatically be deleted. Created a ticket to add this functionality.



As a temporary workaround, whenever I make big updates to the game, I delete liveupdate.arcd, liveupdate.arci and liveupdate.arci.tmp, then call sys.reboot():

local function delete_previous_resources()
  if not env.apkx_main_version or not misc then return false end

  local game_name = sys.get_config("project.title")
  local liveupdate_version_filename = sys.get_save_file(game_name, "liveupdate_version")
  local config = sys.load(liveupdate_version_filename)
  local liveupdate_version = config.liveupdate_version

  if liveupdate_version ~= env.apkx_main_version then
    local deleted_file1 = misc.delete_file(sys.get_save_file(game_name, "liveupdate.arcd"))
    local deleted_file2 = misc.delete_file(sys.get_save_file(game_name, "liveupdate.arci"))
    local deleted_file3 = misc.delete_file(sys.get_save_file(game_name, "liveupdate.arci.tmp"))

    config.liveupdate_version = env.apkx_main_version, config)

    if deleted_file1 or deleted_file2 or deleted_file3 then
      return true

  return false

where misc.delete_file(file_name) is a NE function that returns true if unlink(file_name) == 0