refactor: remove unused mod info and organize some stuff

This commit is contained in:
flow
2022-04-15 22:07:35 -03:00
committed by flow
parent 5a34e8fd7c
commit e9fb566c07
7 changed files with 67 additions and 95 deletions

View File

@ -3,32 +3,30 @@
#include "modplatform/packwiz/Packwiz.h"
ModFolderLoadTask::ModFolderLoadTask(QDir& mods_dir, QDir& index_dir) :
m_mods_dir(mods_dir), m_index_dir(index_dir), m_result(new Result())
{
}
ModFolderLoadTask::ModFolderLoadTask(QDir& mods_dir, QDir& index_dir)
: m_mods_dir(mods_dir), m_index_dir(index_dir), m_result(new Result())
{}
void ModFolderLoadTask::run()
{
// Read metadata first
m_index_dir.refresh();
for(auto entry : m_index_dir.entryList()){
for (auto entry : m_index_dir.entryList()) {
// QDir::Filter::NoDotAndDotDot seems to exclude all files for some reason...
if(entry == "." || entry == "..")
if (entry == "." || entry == "..")
continue;
entry.chop(5); // Remove .toml at the end
entry.chop(5); // Remove .toml at the end
Mod mod(m_mods_dir, Packwiz::getIndexForMod(m_index_dir, entry));
m_result->mods[mod.mmc_id()] = mod;
m_result->mods[mod.internal_id()] = mod;
}
// Read JAR files that don't have metadata
m_mods_dir.refresh();
for (auto entry : m_mods_dir.entryInfoList())
{
for (auto entry : m_mods_dir.entryInfoList()) {
Mod mod(entry);
if(!m_result->mods.contains(mod.mmc_id()))
m_result->mods[mod.mmc_id()] = mod;
if (!m_result->mods.contains(mod.internal_id()))
m_result->mods[mod.internal_id()] = mod;
}
emit succeeded();