2022-05-11 04:27:47 +05:30
|
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
/*
|
|
|
|
* PolyMC - Minecraft Launcher
|
|
|
|
* Copyright (c) 2022 flowln <flowlnlnln@gmail.com>
|
2022-06-12 17:20:58 +05:30
|
|
|
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
2022-05-11 04:27:47 +05:30
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, version 3.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2022-04-14 03:46:36 +05:30
|
|
|
|
2022-05-11 04:27:47 +05:30
|
|
|
#include "LocalModUpdateTask.h"
|
2022-04-14 03:46:36 +05:30
|
|
|
|
2022-04-17 18:49:23 +05:30
|
|
|
#include "Application.h"
|
2022-04-14 03:46:36 +05:30
|
|
|
#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();
|
|
|
|
}
|
|
|
|
|
2022-04-20 04:49:51 +05:30
|
|
|
auto LocalModUpdateTask::abort() -> bool
|
2022-04-14 03:46:36 +05:30
|
|
|
{
|
|
|
|
emitAborted();
|
|
|
|
return true;
|
|
|
|
}
|