From bee50ca7fa0df561f7b65ff7099974085fb5f25e Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Mon, 2 Aug 2021 20:05:10 +0100 Subject: [PATCH] ContentDB: Add support for package aliases / renaming (#11484) --- builtin/mainmenu/dlg_contentstore.lua | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/builtin/mainmenu/dlg_contentstore.lua b/builtin/mainmenu/dlg_contentstore.lua index 7096c9187..a3c72aee4 100644 --- a/builtin/mainmenu/dlg_contentstore.lua +++ b/builtin/mainmenu/dlg_contentstore.lua @@ -575,6 +575,7 @@ function store.load() end store.packages_full = core.parse_json(response.data) or {} + store.aliases = {} for _, package in pairs(store.packages_full) do local name_len = #package.name @@ -583,6 +584,16 @@ function store.load() else package.id = package.author:lower() .. "/" .. package.name end + + if package.aliases then + for _, alias in ipairs(package.aliases) do + -- We currently don't support name changing + local suffix = "/" .. package.name + if alias:sub(-#suffix) == suffix then + store.aliases[alias:lower()] = package.id + end + end + end end store.packages_full_unordered = store.packages_full @@ -595,7 +606,8 @@ function store.update_paths() pkgmgr.refresh_globals() for _, mod in pairs(pkgmgr.global_mods:get_list()) do if mod.author and mod.release > 0 then - mod_hash[mod.author:lower() .. "/" .. mod.name] = mod + local id = mod.author:lower() .. "/" .. mod.name + mod_hash[store.aliases[id] or id] = mod end end @@ -603,14 +615,16 @@ function store.update_paths() pkgmgr.update_gamelist() for _, game in pairs(pkgmgr.games) do if game.author ~= "" and game.release > 0 then - game_hash[game.author:lower() .. "/" .. game.id] = game + local id = game.author:lower() .. "/" .. game.id + game_hash[store.aliases[id] or id] = game end end local txp_hash = {} for _, txp in pairs(pkgmgr.get_texture_packs()) do if txp.author and txp.release > 0 then - txp_hash[txp.author:lower() .. "/" .. txp.name] = txp + local id = txp.author:lower() .. "/" .. txp.name + txp_hash[store.aliases[id] or id] = txp end end