mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-12 16:15:20 +02:00
Do not discover mod directories that fail parsing (#15917)
The root issue of the unit test failure is that all directories that are found in the mod search are counted as mods, even if they are detected to be invalid as such by the parser. For example, the presence of an init.lua file is required, and the parser will return false if one is not found. This return value was completely ignored. Simply counting the mod conditionally on the parsing success makes the modserver tests pass on MSVC.
This commit is contained in:
@@ -175,8 +175,9 @@ std::map<std::string, ModSpec> getModsInPath(
|
||||
mod_virtual_path.append(virtual_path).append("/").append(modname);
|
||||
|
||||
ModSpec spec(modname, mod_path, part_of_modpack, mod_virtual_path);
|
||||
parseModContents(spec);
|
||||
result[modname] = std::move(spec);
|
||||
if (parseModContents(spec)) {
|
||||
result[modname] = std::move(spec);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@@ -78,7 +78,7 @@ struct ModSpec
|
||||
*
|
||||
* @returns false if not a mod
|
||||
*/
|
||||
bool parseModContents(ModSpec &mod);
|
||||
[[nodiscard]] bool parseModContents(ModSpec &mod);
|
||||
|
||||
/**
|
||||
* Gets a list of all mods and modpacks in path
|
||||
|
@@ -385,7 +385,8 @@ int ModApiMainMenu::l_get_content_info(lua_State *L)
|
||||
if (spec.type == "mod") {
|
||||
ModSpec spec;
|
||||
spec.path = path;
|
||||
parseModContents(spec);
|
||||
// TODO return nothing on failure (needs callers to handle it)
|
||||
static_cast<void>(parseModContents(spec));
|
||||
|
||||
// Dependencies
|
||||
lua_newtable(L);
|
||||
|
Reference in New Issue
Block a user