mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2026-07-03 11:56:57 +03:00
chore(clang-tidy): fix clang tidy warnings
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
parent
ca721f9d67
commit
a63048d7e2
19 changed files with 494 additions and 405 deletions
|
|
@ -32,114 +32,119 @@
|
|||
|
||||
bool ModrinthCreationTask::abort()
|
||||
{
|
||||
if (!canAbort())
|
||||
if (!canAbort()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_task)
|
||||
if (m_task) {
|
||||
m_task->abort();
|
||||
}
|
||||
return InstanceCreationTask::abort();
|
||||
}
|
||||
|
||||
bool ModrinthCreationTask::updateInstance()
|
||||
{
|
||||
auto instance_list = APPLICATION->instances();
|
||||
auto* instanceList = APPLICATION->instances();
|
||||
|
||||
// FIXME: How to handle situations when there's more than one install already for a given modpack?
|
||||
BaseInstance* inst;
|
||||
if (auto original_id = originalInstanceID(); !original_id.isEmpty()) {
|
||||
inst = instance_list->getInstanceById(original_id);
|
||||
BaseInstance* inst = nullptr;
|
||||
if (auto originalId = originalInstanceID(); !originalId.isEmpty()) {
|
||||
inst = instanceList->getInstanceById(originalId);
|
||||
Q_ASSERT(inst);
|
||||
} else {
|
||||
inst = instance_list->getInstanceByManagedName(originalName());
|
||||
inst = instanceList->getInstanceByManagedName(originalName());
|
||||
|
||||
if (!inst) {
|
||||
inst = instance_list->getInstanceById(originalName());
|
||||
inst = instanceList->getInstanceById(originalName());
|
||||
|
||||
if (!inst)
|
||||
if (!inst) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QString index_path = FS::PathCombine(m_stagingPath, "modrinth.index.json");
|
||||
if (!parseManifest(index_path, m_files, true, false))
|
||||
QString indexPath = FS::PathCombine(m_stagingPath, "modrinth.index.json");
|
||||
if (!parseManifest(indexPath, m_files, true, false)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto version_name = inst->getManagedPackVersionName();
|
||||
auto versionName = inst->getManagedPackVersionName();
|
||||
m_root_path = QFileInfo(inst->gameRoot()).fileName();
|
||||
auto version_str = !version_name.isEmpty() ? tr(" (version %1)").arg(version_name) : "";
|
||||
auto versionStr = !versionName.isEmpty() ? tr(" (version %1)").arg(versionName) : "";
|
||||
|
||||
if (shouldConfirmUpdate()) {
|
||||
auto should_update = askIfShouldUpdate(m_parent, version_str);
|
||||
if (should_update == ShouldUpdate::SkipUpdating)
|
||||
auto shouldUpdate = askIfShouldUpdate(m_parent, versionStr);
|
||||
if (shouldUpdate == ShouldUpdate::SkipUpdating) {
|
||||
return false;
|
||||
if (should_update == ShouldUpdate::Cancel) {
|
||||
}
|
||||
if (shouldUpdate == ShouldUpdate::Cancel) {
|
||||
m_abort = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Remove repeated files, we don't need to download them!
|
||||
QDir old_inst_dir(inst->instanceRoot());
|
||||
QDir oldInstDir(inst->instanceRoot());
|
||||
|
||||
QString old_index_folder(FS::PathCombine(old_inst_dir.absolutePath(), "mrpack"));
|
||||
QString oldIndexFolder(FS::PathCombine(oldInstDir.absolutePath(), "mrpack"));
|
||||
|
||||
QString old_index_path(FS::PathCombine(old_index_folder, "modrinth.index.json"));
|
||||
QFileInfo old_index_file(old_index_path);
|
||||
if (old_index_file.exists()) {
|
||||
std::vector<File> old_files;
|
||||
parseManifest(old_index_path, old_files, false, false);
|
||||
QString oldIndexPath(FS::PathCombine(oldIndexFolder, "modrinth.index.json"));
|
||||
QFileInfo oldIndexFile(oldIndexPath);
|
||||
if (oldIndexFile.exists()) {
|
||||
std::vector<File> oldFiles;
|
||||
parseManifest(oldIndexPath, oldFiles, false, false);
|
||||
|
||||
// Let's remove all duplicated, identical resources!
|
||||
auto files_iterator = m_files.begin();
|
||||
auto filesIterator = m_files.begin();
|
||||
begin:
|
||||
while (files_iterator != m_files.end()) {
|
||||
auto const& file = *files_iterator;
|
||||
while (filesIterator != m_files.end()) {
|
||||
const auto& file = *filesIterator;
|
||||
|
||||
auto old_files_iterator = old_files.begin();
|
||||
while (old_files_iterator != old_files.end()) {
|
||||
auto const& old_file = *old_files_iterator;
|
||||
auto oldFilesIterator = oldFiles.begin();
|
||||
while (oldFilesIterator != oldFiles.end()) {
|
||||
const auto& oldFile = *oldFilesIterator;
|
||||
|
||||
if (old_file.hash == file.hash) {
|
||||
if (oldFile.hash == file.hash) {
|
||||
qDebug() << "Removed file at" << file.path << "from list of downloads";
|
||||
files_iterator = m_files.erase(files_iterator);
|
||||
old_files_iterator = old_files.erase(old_files_iterator);
|
||||
filesIterator = m_files.erase(filesIterator);
|
||||
oldFilesIterator = oldFiles.erase(oldFilesIterator);
|
||||
goto begin; // Sorry :c
|
||||
}
|
||||
|
||||
old_files_iterator++;
|
||||
oldFilesIterator++;
|
||||
}
|
||||
|
||||
files_iterator++;
|
||||
filesIterator++;
|
||||
}
|
||||
|
||||
QDir old_minecraft_dir(inst->gameRoot());
|
||||
QDir oldMinecraftDir(inst->gameRoot());
|
||||
|
||||
// Some files were removed from the old version, and some will be downloaded in an updated version,
|
||||
// so we're fine removing them!
|
||||
if (!old_files.empty()) {
|
||||
for (auto const& file : old_files) {
|
||||
scheduleToDelete(m_parent, old_minecraft_dir, file.path, true);
|
||||
if (!oldFiles.empty()) {
|
||||
for (const auto& file : oldFiles) {
|
||||
scheduleToDelete(m_parent, oldMinecraftDir, file.path, true);
|
||||
}
|
||||
}
|
||||
|
||||
// We will remove all the previous overrides, to prevent duplicate files!
|
||||
// TODO: Currently 'overrides' will always override the stuff on update. How do we preserve unchanged overrides?
|
||||
// FIXME: We may want to do something about disabled mods.
|
||||
auto old_overrides = Override::readOverrides("overrides", old_index_folder);
|
||||
for (const auto& entry : old_overrides) {
|
||||
scheduleToDelete(m_parent, old_minecraft_dir, entry);
|
||||
auto oldOverrides = Override::readOverrides("overrides", oldIndexFolder);
|
||||
for (const auto& entry : oldOverrides) {
|
||||
scheduleToDelete(m_parent, oldMinecraftDir, entry);
|
||||
}
|
||||
|
||||
auto old_client_overrides = Override::readOverrides("client-overrides", old_index_folder);
|
||||
for (const auto& entry : old_client_overrides) {
|
||||
scheduleToDelete(m_parent, old_minecraft_dir, entry);
|
||||
auto oldClientOverrides = Override::readOverrides("client-overrides", oldIndexFolder);
|
||||
for (const auto& entry : oldClientOverrides) {
|
||||
scheduleToDelete(m_parent, oldMinecraftDir, entry);
|
||||
}
|
||||
} else {
|
||||
// We don't have an old index file, so we may duplicate stuff!
|
||||
auto dialog = CustomMessageBox::selectable(m_parent, tr("No index file."),
|
||||
tr("We couldn't find a suitable index file for the older version. This may cause some "
|
||||
"of the files to be duplicated. Do you want to continue?"),
|
||||
QMessageBox::Warning, QMessageBox::Ok | QMessageBox::Cancel);
|
||||
auto* dialog = CustomMessageBox::selectable(m_parent, tr("No index file."),
|
||||
tr("We couldn't find a suitable index file for the older version. This may cause some "
|
||||
"of the files to be duplicated. Do you want to continue?"),
|
||||
QMessageBox::Warning, QMessageBox::Ok | QMessageBox::Cancel);
|
||||
|
||||
if (dialog->exec() == QDialog::DialogCode::Rejected) {
|
||||
m_abort = true;
|
||||
|
|
@ -161,39 +166,40 @@ std::unique_ptr<MinecraftInstance> ModrinthCreationTask::createInstance()
|
|||
{
|
||||
QEventLoop loop;
|
||||
|
||||
QString parent_folder(FS::PathCombine(m_stagingPath, "mrpack"));
|
||||
QString parentFolder(FS::PathCombine(m_stagingPath, "mrpack"));
|
||||
|
||||
QString index_path = FS::PathCombine(m_stagingPath, "modrinth.index.json");
|
||||
if (m_files.empty() && !parseManifest(index_path, m_files, true, true))
|
||||
QString indexPath = FS::PathCombine(m_stagingPath, "modrinth.index.json");
|
||||
if (m_files.empty() && !parseManifest(indexPath, m_files, true, true)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Keep index file in case we need it some other time (like when changing versions)
|
||||
QString new_index_place(FS::PathCombine(parent_folder, "modrinth.index.json"));
|
||||
FS::ensureFilePathExists(new_index_place);
|
||||
FS::move(index_path, new_index_place);
|
||||
QString newIndexPlace(FS::PathCombine(parentFolder, "modrinth.index.json"));
|
||||
FS::ensureFilePathExists(newIndexPlace);
|
||||
FS::move(indexPath, newIndexPlace);
|
||||
|
||||
auto mcPath = FS::PathCombine(m_stagingPath, m_root_path);
|
||||
|
||||
auto override_path = FS::PathCombine(m_stagingPath, "overrides");
|
||||
if (QFile::exists(override_path)) {
|
||||
auto overridePath = FS::PathCombine(m_stagingPath, "overrides");
|
||||
if (QFile::exists(overridePath)) {
|
||||
// Create a list of overrides in "overrides.txt" inside mrpack/
|
||||
Override::createOverrides("overrides", parent_folder, override_path);
|
||||
Override::createOverrides("overrides", parentFolder, overridePath);
|
||||
|
||||
// Apply the overrides
|
||||
if (!FS::move(override_path, mcPath)) {
|
||||
if (!FS::move(overridePath, mcPath)) {
|
||||
setError(tr("Could not rename the overrides folder:\n") + "overrides");
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
// Do client overrides
|
||||
auto client_override_path = FS::PathCombine(m_stagingPath, "client-overrides");
|
||||
if (QFile::exists(client_override_path)) {
|
||||
auto clientOverridePath = FS::PathCombine(m_stagingPath, "client-overrides");
|
||||
if (QFile::exists(clientOverridePath)) {
|
||||
// Create a list of overrides in "client-overrides.txt" inside mrpack/
|
||||
Override::createOverrides("client-overrides", parent_folder, client_override_path);
|
||||
Override::createOverrides("client-overrides", parentFolder, clientOverridePath);
|
||||
|
||||
// Apply the overrides
|
||||
if (!FS::overrideFolder(mcPath, client_override_path)) {
|
||||
if (!FS::overrideFolder(mcPath, clientOverridePath)) {
|
||||
setError(tr("Could not rename the client overrides folder:\n") + "client overrides");
|
||||
return nullptr;
|
||||
}
|
||||
|
|
@ -203,18 +209,22 @@ std::unique_ptr<MinecraftInstance> ModrinthCreationTask::createInstance()
|
|||
auto instanceSettings = std::make_unique<INISettingsObject>(configPath);
|
||||
auto instance = std::make_unique<MinecraftInstance>(m_globalSettings, std::move(instanceSettings), m_stagingPath);
|
||||
|
||||
auto components = instance->getPackProfile();
|
||||
auto* components = instance->getPackProfile();
|
||||
components->buildingFromScratch();
|
||||
components->setComponentVersion("net.minecraft", m_minecraft_version, true);
|
||||
|
||||
if (!m_fabric_version.isEmpty())
|
||||
if (!m_fabric_version.isEmpty()) {
|
||||
components->setComponentVersion("net.fabricmc.fabric-loader", m_fabric_version);
|
||||
if (!m_quilt_version.isEmpty())
|
||||
}
|
||||
if (!m_quilt_version.isEmpty()) {
|
||||
components->setComponentVersion("org.quiltmc.quilt-loader", m_quilt_version);
|
||||
if (!m_forge_version.isEmpty())
|
||||
}
|
||||
if (!m_forge_version.isEmpty()) {
|
||||
components->setComponentVersion("net.minecraftforge", m_forge_version);
|
||||
if (!m_neoForge_version.isEmpty())
|
||||
}
|
||||
if (!m_neoForge_version.isEmpty()) {
|
||||
components->setComponentVersion("net.neoforged", m_neoForge_version);
|
||||
}
|
||||
|
||||
if (m_instIcon != "default") {
|
||||
instance->setIconKey(m_instIcon);
|
||||
|
|
@ -223,34 +233,35 @@ std::unique_ptr<MinecraftInstance> ModrinthCreationTask::createInstance()
|
|||
}
|
||||
|
||||
// Don't add managed info to packs without an ID (most likely imported from ZIP)
|
||||
if (!m_managed_id.isEmpty())
|
||||
if (!m_managed_id.isEmpty()) {
|
||||
instance->setManagedPack("modrinth", m_managed_id, m_managed_name, m_managed_version_id, version());
|
||||
else
|
||||
} else {
|
||||
instance->setManagedPack("modrinth", "", name(), "", "");
|
||||
}
|
||||
|
||||
instance->setName(name());
|
||||
instance->saveNow();
|
||||
|
||||
auto downloadMods = makeShared<NetJob>(tr("Mod Download Modrinth"), APPLICATION->network());
|
||||
|
||||
auto root_modpack_path = FS::PathCombine(m_stagingPath, m_root_path);
|
||||
auto root_modpack_url = QUrl::fromLocalFile(root_modpack_path);
|
||||
auto rootModpackPath = FS::PathCombine(m_stagingPath, m_root_path);
|
||||
auto rootModpackUrl = QUrl::fromLocalFile(rootModpackPath);
|
||||
// TODO make this work with other sorts of resource
|
||||
QHash<QString, Resource*> resources;
|
||||
for (auto& file : m_files) {
|
||||
auto fileName = file.path;
|
||||
fileName = FS::RemoveInvalidPathChars(fileName);
|
||||
auto file_path = FS::PathCombine(root_modpack_path, fileName);
|
||||
if (!root_modpack_url.isParentOf(QUrl::fromLocalFile(file_path))) {
|
||||
auto filePath = FS::PathCombine(rootModpackPath, fileName);
|
||||
if (!rootModpackUrl.isParentOf(QUrl::fromLocalFile(filePath))) {
|
||||
// This means we somehow got out of the root folder, so abort here to prevent exploits
|
||||
setError(tr("One of the files has a path that leads to an arbitrary location (%1). This is a security risk and isn't allowed.")
|
||||
.arg(fileName));
|
||||
return nullptr;
|
||||
}
|
||||
if (fileName.startsWith("mods/")) {
|
||||
auto mod = new Mod(file_path);
|
||||
auto* mod = new Mod(filePath);
|
||||
ModDetails d;
|
||||
d.mod_id = file_path;
|
||||
d.mod_id = filePath;
|
||||
mod->setDetails(d);
|
||||
resources[file.hash.toHex()] = mod;
|
||||
}
|
||||
|
|
@ -258,7 +269,7 @@ std::unique_ptr<MinecraftInstance> ModrinthCreationTask::createInstance()
|
|||
setError(tr("The file '%1' is missing a download link. This is invalid in the pack format.").arg(fileName));
|
||||
return nullptr;
|
||||
}
|
||||
qDebug() << "Will try to download" << file.downloads.front() << "to" << file_path;
|
||||
qDebug() << "Will try to download" << file.downloads.front() << "to" << filePath;
|
||||
|
||||
QString loader;
|
||||
if (m_instance.has_value()) {
|
||||
|
|
@ -281,29 +292,30 @@ std::unique_ptr<MinecraftInstance> ModrinthCreationTask::createInstance()
|
|||
};
|
||||
|
||||
QUrl downloadUrl = file.downloads.dequeue();
|
||||
auto dl = Net::ApiDownload::makeFile(downloadUrl, file_path, Net::Download::Option::NoOptions, meta);
|
||||
auto dl = Net::ApiDownload::makeFile(downloadUrl, filePath, Net::Download::Option::NoOptions, meta);
|
||||
dl->addValidator(new Net::ChecksumValidator(file.hashAlgorithm, file.hash));
|
||||
downloadMods->addNetAction(dl);
|
||||
if (!file.downloads.empty()) {
|
||||
// FIXME: This really needs to be put into a ConcurrentTask of
|
||||
// MultipleOptionsTask's , once those exist :)
|
||||
auto param = dl.toWeakRef();
|
||||
connect(dl.get(), &Task::failed, [&file, file_path, param, downloadMods, meta] {
|
||||
connect(dl.get(), &Task::failed, [&file, filePath, param, downloadMods, meta] {
|
||||
QUrl fallbackUrl = file.downloads.dequeue();
|
||||
auto ndl = Net::ApiDownload::makeFile(fallbackUrl, file_path, Net::Download::Option::NoOptions, meta);
|
||||
auto ndl = Net::ApiDownload::makeFile(fallbackUrl, filePath, Net::Download::Option::NoOptions, meta);
|
||||
ndl->addValidator(new Net::ChecksumValidator(file.hashAlgorithm, file.hash));
|
||||
downloadMods->addNetAction(ndl);
|
||||
if (auto shared = param.lock())
|
||||
if (auto shared = param.lock()) {
|
||||
shared->succeeded();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
bool ended_well = false;
|
||||
bool endedWell = false;
|
||||
|
||||
connect(downloadMods.get(), &NetJob::succeeded, this, [&ended_well]() { ended_well = true; });
|
||||
connect(downloadMods.get(), &NetJob::failed, [this, &ended_well](const QString& reason) {
|
||||
ended_well = false;
|
||||
connect(downloadMods.get(), &NetJob::succeeded, this, [&endedWell]() { endedWell = true; });
|
||||
connect(downloadMods.get(), &NetJob::failed, [this, &endedWell](const QString& reason) {
|
||||
endedWell = false;
|
||||
setError(reason);
|
||||
});
|
||||
connect(downloadMods.get(), &NetJob::finished, &loop, &QEventLoop::quit);
|
||||
|
|
@ -319,8 +331,8 @@ std::unique_ptr<MinecraftInstance> ModrinthCreationTask::createInstance()
|
|||
|
||||
loop.exec();
|
||||
|
||||
if (!ended_well) {
|
||||
for (auto resource : resources) {
|
||||
if (!endedWell) {
|
||||
for (auto* resource : resources) {
|
||||
delete resource;
|
||||
}
|
||||
return nullptr;
|
||||
|
|
@ -329,7 +341,7 @@ std::unique_ptr<MinecraftInstance> ModrinthCreationTask::createInstance()
|
|||
QEventLoop ensureMetaLoop;
|
||||
QDir folder = FS::PathCombine(instance->modsRoot(), ".index");
|
||||
auto ensureMetadataTask = makeShared<EnsureMetadataTask>(resources, folder, ModPlatform::ResourceProvider::MODRINTH);
|
||||
connect(ensureMetadataTask.get(), &Task::succeeded, this, [&ended_well]() { ended_well = true; });
|
||||
connect(ensureMetadataTask.get(), &Task::succeeded, this, [&endedWell]() { endedWell = true; });
|
||||
connect(ensureMetadataTask.get(), &Task::finished, &ensureMetaLoop, &QEventLoop::quit);
|
||||
connect(ensureMetadataTask.get(), &Task::progress, [this](qint64 current, qint64 total) {
|
||||
setDetails(tr("%1 out of %2 complete").arg(current).arg(total));
|
||||
|
|
@ -341,40 +353,38 @@ std::unique_ptr<MinecraftInstance> ModrinthCreationTask::createInstance()
|
|||
m_task = ensureMetadataTask;
|
||||
|
||||
ensureMetaLoop.exec();
|
||||
for (auto resource : resources) {
|
||||
for (auto* resource : resources) {
|
||||
delete resource;
|
||||
}
|
||||
resources.clear();
|
||||
|
||||
// Update information of the already installed instance, if any.
|
||||
if (m_instance && ended_well) {
|
||||
if (m_instance && endedWell) {
|
||||
setAbortable(false);
|
||||
auto inst = m_instance.value();
|
||||
auto* inst = m_instance.value();
|
||||
|
||||
// Only change the name if it didn't use a custom name, so that the previous custom name
|
||||
// is preserved, but if we're using the original one, we update the version string.
|
||||
// NOTE: This needs to come before the copyManagedPack call!
|
||||
if (inst->name().contains(inst->getManagedPackVersionName()) && inst->name() != instance->name()) {
|
||||
if (askForChangingInstanceName(m_parent, inst->name(), instance->name()) == InstanceNameChange::ShouldChange)
|
||||
if (askForChangingInstanceName(m_parent, inst->name(), instance->name()) == InstanceNameChange::ShouldChange) {
|
||||
inst->setName(instance->name());
|
||||
}
|
||||
}
|
||||
|
||||
inst->copyManagedPack(*instance);
|
||||
}
|
||||
|
||||
if (ended_well) {
|
||||
if (endedWell) {
|
||||
return instance;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool ModrinthCreationTask::parseManifest(const QString& index_path,
|
||||
std::vector<File>& files,
|
||||
bool set_internal_data,
|
||||
bool show_optional_dialog)
|
||||
bool ModrinthCreationTask::parseManifest(const QString& indexPath, std::vector<File>& files, bool setInternalData, bool showOptionalDialog)
|
||||
{
|
||||
try {
|
||||
auto doc = Json::requireDocument(index_path);
|
||||
auto doc = Json::requireDocument(indexPath);
|
||||
auto obj = Json::requireObject(doc, "modrinth.index.json");
|
||||
int formatVersion = Json::requireInteger(obj, "formatVersion", "modrinth.index.json");
|
||||
if (formatVersion == 1) {
|
||||
|
|
@ -383,9 +393,10 @@ bool ModrinthCreationTask::parseManifest(const QString& index_path,
|
|||
throw JSONValidationError("Unknown game: " + game);
|
||||
}
|
||||
|
||||
if (set_internal_data) {
|
||||
if (m_managed_version_id.isEmpty())
|
||||
if (setInternalData) {
|
||||
if (m_managed_version_id.isEmpty()) {
|
||||
m_managed_version_id = obj["versionId"].toString();
|
||||
}
|
||||
m_managed_name = obj["name"].toString();
|
||||
}
|
||||
|
||||
|
|
@ -401,7 +412,8 @@ bool ModrinthCreationTask::parseManifest(const QString& index_path,
|
|||
QString support = env["client"].toString("unsupported");
|
||||
if (support == "unsupported") {
|
||||
continue;
|
||||
} else if (support == "optional") {
|
||||
}
|
||||
if (support == "optional") {
|
||||
file.required = false;
|
||||
}
|
||||
}
|
||||
|
|
@ -413,20 +425,21 @@ bool ModrinthCreationTask::parseManifest(const QString& index_path,
|
|||
// Do not use requireUrl, which uses StrictMode, instead use QUrl's default TolerantMode
|
||||
// (as Modrinth seems to incorrectly handle spaces)
|
||||
|
||||
auto download_arr = modInfo["downloads"].toArray();
|
||||
for (auto download : download_arr) {
|
||||
auto downloadArr = modInfo["downloads"].toArray();
|
||||
for (auto download : downloadArr) {
|
||||
qWarning() << download.toString();
|
||||
bool is_last = download.toString() == download_arr.last().toString();
|
||||
bool isLast = download.toString() == downloadArr.last().toString();
|
||||
|
||||
auto download_url = QUrl(download.toString());
|
||||
auto downloadUrl = QUrl(download.toString());
|
||||
|
||||
if (!download_url.isValid()) {
|
||||
if (!downloadUrl.isValid()) {
|
||||
qDebug()
|
||||
<< QString("Download URL (%1) for %2 is not a correctly formatted URL").arg(download_url.toString(), file.path);
|
||||
if (is_last && file.downloads.isEmpty())
|
||||
<< QString("Download URL (%1) for %2 is not a correctly formatted URL").arg(downloadUrl.toString(), file.path);
|
||||
if (isLast && file.downloads.isEmpty()) {
|
||||
throw JSONValidationError(tr("Download URL for %1 is not a correctly formatted URL").arg(file.path));
|
||||
}
|
||||
} else {
|
||||
file.downloads.push_back(download_url);
|
||||
file.downloads.push_back(downloadUrl);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -434,10 +447,11 @@ bool ModrinthCreationTask::parseManifest(const QString& index_path,
|
|||
}
|
||||
|
||||
if (!optionalFiles.empty()) {
|
||||
if (show_optional_dialog) {
|
||||
if (showOptionalDialog) {
|
||||
QStringList oFiles;
|
||||
for (auto file : optionalFiles)
|
||||
for (const auto& file : optionalFiles) {
|
||||
oFiles.push_back(file.path);
|
||||
}
|
||||
OptionalModDialog optionalModDialog(m_parent, oFiles);
|
||||
if (optionalModDialog.exec() == QDialog::Rejected) {
|
||||
emitAborted();
|
||||
|
|
@ -460,7 +474,7 @@ bool ModrinthCreationTask::parseManifest(const QString& index_path,
|
|||
}
|
||||
}
|
||||
}
|
||||
if (set_internal_data) {
|
||||
if (setInternalData) {
|
||||
auto dependencies = Json::requireObject(obj, "dependencies", "modrinth.index.json");
|
||||
for (auto it = dependencies.begin(), end = dependencies.end(); it != end; ++it) {
|
||||
QString name = it.key();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue