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()
resource.delete_stored_resource(resource_hash_or_table_of_resource_hashes)
3 Likes

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.

https://github.com/defold/defold/issues/4722

3 Likes

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

Just wondering, does this feature is planned to devoped. I am kinda also interested in this :slight_smile:

It’s on our roadmap: https://github.com/defold/defold/issues/4722

But it has not been assigned to a release yet. And I can’t say when. Not in any of the versions currently planned (1.2.172 and 1.2.173 but maybe 1.2.174)

2 Likes

It is nice to hear! Thanks!

Regarding the original feature request, and the workaround, it seems like a first good step would be to remove any (all) liveupdate data.
Is this correct?

Removing individual files is much more involved, so finding a MVP would be good.

2 Likes

I guess yes, the best solution will be to delete all liveupdate data.

Can be this feature assigned to some release? :slight_smile:

Sorry for the slow reply. We intend to come back to Live Update features once the Rive integration is launched. I can’t say for sure when this will be, but perhaps 6 to 8 weeks from now.

4 Likes