Skip to content
Permalink
Browse files
ContentDB: Add support for package aliases / renaming (#11484)
  • Loading branch information
rubenwardy committed Aug 2, 2021
1 parent 32cb9d0 commit bee50ca7fa0df561f7b65ff7099974085fb5f25e
Showing with 17 additions and 3 deletions.
  1. +17 −3 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,22 +606,25 @@ 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

local game_hash = {}
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

0 comments on commit bee50ca

Please sign in to comment.