fix: typo and useless code

This commit is contained in:
flow 2022-05-16 17:05:54 -03:00
parent cd9e0e0cc0
commit 887246a66b
No known key found for this signature in database
GPG Key ID: 8D0F221F0A59F469
5 changed files with 15 additions and 25 deletions

View File

@ -554,10 +554,10 @@ void InstanceImportTask::processModrinth()
}
file.hash = QByteArray::fromHex(hash.toLatin1());
file.hashAlgorithm = hashAlgorithm;
// Do not use requireUrl, which uses StrictMode, instead use QUrl's default TolerantMode (as Modrinth seems to incorrectly
// handle spaces)
// Do not use requireUrl, which uses StrictMode, instead use QUrl's default TolerantMode
// (as Modrinth seems to incorrectly handle spaces)
file.download = Json::requireString(Json::ensureArray(obj, "downloads").first(), "Download URL for " + file.path);
if (!file.download.isValid() || !Modrinth::validadeDownloadUrl(file.download)) {
if (!file.download.isValid() || !Modrinth::validateDownloadUrl(file.download)) {
throw JSONValidationError("Download URL for " + file.path + " is not a correctly formatted URL");
}
files.push_back(file);
@ -567,22 +567,18 @@ void InstanceImportTask::processModrinth()
for (auto it = dependencies.begin(), end = dependencies.end(); it != end; ++it) {
QString name = it.key();
if (name == "minecraft") {
if (!minecraftVersion.isEmpty())
throw JSONValidationError("Duplicate Minecraft version");
minecraftVersion = Json::requireString(*it, "Minecraft version");
} else if (name == "fabric-loader") {
if (!fabricVersion.isEmpty())
throw JSONValidationError("Duplicate Fabric Loader version");
}
else if (name == "fabric-loader") {
fabricVersion = Json::requireString(*it, "Fabric Loader version");
} else if (name == "quilt-loader") {
if (!quiltVersion.isEmpty())
throw JSONValidationError("Duplicate Quilt Loader version");
}
else if (name == "quilt-loader") {
quiltVersion = Json::requireString(*it, "Quilt Loader version");
} else if (name == "forge") {
if (!forgeVersion.isEmpty())
throw JSONValidationError("Duplicate Forge version");
}
else if (name == "forge") {
forgeVersion = Json::requireString(*it, "Forge version");
} else {
}
else {
throw JSONValidationError("Unknown dependency type: " + name);
}
}
@ -594,6 +590,7 @@ void InstanceImportTask::processModrinth()
emitFailed(tr("Could not understand pack index:\n") + e.cause());
return;
}
QString overridePath = FS::PathCombine(m_stagingPath, "overrides");
if (QFile::exists(overridePath)) {
QString mcPath = FS::PathCombine(m_stagingPath, ".minecraft");

View File

@ -93,7 +93,7 @@ void loadIndexedVersions(Modpack& pack, QJsonDocument& doc)
pack.versionsLoaded = true;
}
auto validadeDownloadUrl(QUrl url) -> bool
auto validateDownloadUrl(QUrl url) -> bool
{
auto domain = url.host();
if(domain == "cdn.modrinth.com")
@ -139,7 +139,7 @@ auto loadIndexedVersion(QJsonObject &obj) -> ModpackVersion
auto url = Json::requireString(parent, "url");
if(!validadeDownloadUrl(url))
if(!validateDownloadUrl(url))
continue;
file.download_url = url;

View File

@ -99,7 +99,7 @@ void loadIndexedInfo(Modpack&, QJsonObject&);
void loadIndexedVersions(Modpack&, QJsonDocument&);
auto loadIndexedVersion(QJsonObject&) -> ModpackVersion;
auto validadeDownloadUrl(QUrl) -> bool;
auto validateDownloadUrl(QUrl) -> bool;
}

View File

@ -195,7 +195,6 @@ void ModrinthPage::onSelectionChanged(QModelIndex first, QModelIndex second)
ui->versionSelectionBox->addItem(version.version, QVariant(version.id));
}
updateVersionsUI();
suggestCurrent();
});
QObject::connect(netJob, &NetJob::finished, this, [response, netJob] {
@ -233,11 +232,6 @@ void ModrinthPage::updateUI()
ui->packDescription->setHtml(text + current.description);
}
void ModrinthPage::updateVersionsUI()
{
// idk
}
void ModrinthPage::suggestCurrent()
{
if (!isOpened) {

View File

@ -71,7 +71,6 @@ class ModrinthPage : public QWidget, public BasePage {
void suggestCurrent();
void updateUI();
void updateVersionsUI();
void retranslate() override;
void openedImpl() override;