summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorrubenwardy <rw@rubenwardy.com>2021-08-02 20:05:10 +0100
committerGitHub <noreply@github.com>2021-08-02 20:05:10 +0100
commitbee50ca7fa0df561f7b65ff7099974085fb5f25e (patch)
treef4323b8eaed984e1fed5e1daae576322c586300a /builtin
parent32cb9d0828828da3068259c9e0a3c0f5da170439 (diff)
downloadminetest-bee50ca7fa0df561f7b65ff7099974085fb5f25e.tar.gz
minetest-bee50ca7fa0df561f7b65ff7099974085fb5f25e.tar.bz2
minetest-bee50ca7fa0df561f7b65ff7099974085fb5f25e.zip
ContentDB: Add support for package aliases / renaming (#11484)
Diffstat (limited to 'builtin')
-rw-r--r--builtin/mainmenu/dlg_contentstore.lua20
1 files 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