Skip to content

Commit bee50ca

Browse files
authoredAug 2, 2021
ContentDB: Add support for package aliases / renaming (#11484)
1 parent 32cb9d0 commit bee50ca

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed
 

‎builtin/mainmenu/dlg_contentstore.lua

+17-3
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,7 @@ function store.load()
575575
end
576576

577577
store.packages_full = core.parse_json(response.data) or {}
578+
store.aliases = {}
578579

579580
for _, package in pairs(store.packages_full) do
580581
local name_len = #package.name
@@ -583,6 +584,16 @@ function store.load()
583584
else
584585
package.id = package.author:lower() .. "/" .. package.name
585586
end
587+
588+
if package.aliases then
589+
for _, alias in ipairs(package.aliases) do
590+
-- We currently don't support name changing
591+
local suffix = "/" .. package.name
592+
if alias:sub(-#suffix) == suffix then
593+
store.aliases[alias:lower()] = package.id
594+
end
595+
end
596+
end
586597
end
587598

588599
store.packages_full_unordered = store.packages_full
@@ -595,22 +606,25 @@ function store.update_paths()
595606
pkgmgr.refresh_globals()
596607
for _, mod in pairs(pkgmgr.global_mods:get_list()) do
597608
if mod.author and mod.release > 0 then
598-
mod_hash[mod.author:lower() .. "/" .. mod.name] = mod
609+
local id = mod.author:lower() .. "/" .. mod.name
610+
mod_hash[store.aliases[id] or id] = mod
599611
end
600612
end
601613

602614
local game_hash = {}
603615
pkgmgr.update_gamelist()
604616
for _, game in pairs(pkgmgr.games) do
605617
if game.author ~= "" and game.release > 0 then
606-
game_hash[game.author:lower() .. "/" .. game.id] = game
618+
local id = game.author:lower() .. "/" .. game.id
619+
game_hash[store.aliases[id] or id] = game
607620
end
608621
end
609622

610623
local txp_hash = {}
611624
for _, txp in pairs(pkgmgr.get_texture_packs()) do
612625
if txp.author and txp.release > 0 then
613-
txp_hash[txp.author:lower() .. "/" .. txp.name] = txp
626+
local id = txp.author:lower() .. "/" .. txp.name
627+
txp_hash[store.aliases[id] or id] = txp
614628
end
615629
end
616630

0 commit comments

Comments
 (0)
Please sign in to comment.