Live Update: Delete resource

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
    sys.save(liveupdate_version_filename, config)

    if deleted_file1 or deleted_file2 or deleted_file3 then
      sys.reboot()
      return true
    end
  end

  return false
end

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

2 Likes