mirror of
https://github.com/minetest/minetest.git
synced 2024-12-23 14:42:24 +01:00
ContentDB: Add support for package aliases / renaming (#11484)
This commit is contained in:
parent
32cb9d0828
commit
bee50ca7fa
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user