2022-04-14 03:46:36 +05:30
|
|
|
#include "LocalModUpdateTask.h"
|
|
|
|
|
|
|
|
#include <toml.h>
|
|
|
|
|
|
|
|
#include "FileSystem.h"
|
2022-04-16 21:57:29 +05:30
|
|
|
#include "minecraft/mod/MetadataHandler.h"
|
2022-04-14 03:46:36 +05:30
|
|
|
|
2022-04-15 06:32:41 +05:30
|
|
|
LocalModUpdateTask::LocalModUpdateTask(QDir index_dir, ModPlatform::IndexedPack& mod, ModPlatform::IndexedVersion& mod_version)
|
|
|
|
: m_index_dir(index_dir), m_mod(mod), m_mod_version(mod_version)
|
2022-04-14 03:46:36 +05:30
|
|
|
{
|
|
|
|
// Ensure a '.index' folder exists in the mods folder, and create it if it does not
|
2022-04-15 06:32:41 +05:30
|
|
|
if (!FS::ensureFolderPathExists(index_dir.path())) {
|
2022-04-14 03:46:36 +05:30
|
|
|
emitFailed(QString("Unable to create index for mod %1!").arg(m_mod.name));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void LocalModUpdateTask::executeTask()
|
|
|
|
{
|
|
|
|
setStatus(tr("Updating index for mod:\n%1").arg(m_mod.name));
|
|
|
|
|
2022-04-16 21:57:29 +05:30
|
|
|
auto pw_mod = Metadata::create(m_index_dir, m_mod, m_mod_version);
|
|
|
|
Metadata::update(m_index_dir, pw_mod);
|
2022-04-14 03:46:36 +05:30
|
|
|
|
|
|
|
emitSucceeded();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool LocalModUpdateTask::abort()
|
|
|
|
{
|
|
|
|
emitAborted();
|
|
|
|
return true;
|
|
|
|
}
|