fix: typo and useless code
This commit is contained in:
parent
cd9e0e0cc0
commit
887246a66b
@ -554,10 +554,10 @@ void InstanceImportTask::processModrinth()
|
|||||||
}
|
}
|
||||||
file.hash = QByteArray::fromHex(hash.toLatin1());
|
file.hash = QByteArray::fromHex(hash.toLatin1());
|
||||||
file.hashAlgorithm = hashAlgorithm;
|
file.hashAlgorithm = hashAlgorithm;
|
||||||
// Do not use requireUrl, which uses StrictMode, instead use QUrl's default TolerantMode (as Modrinth seems to incorrectly
|
// Do not use requireUrl, which uses StrictMode, instead use QUrl's default TolerantMode
|
||||||
// handle spaces)
|
// (as Modrinth seems to incorrectly handle spaces)
|
||||||
file.download = Json::requireString(Json::ensureArray(obj, "downloads").first(), "Download URL for " + file.path);
|
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");
|
throw JSONValidationError("Download URL for " + file.path + " is not a correctly formatted URL");
|
||||||
}
|
}
|
||||||
files.push_back(file);
|
files.push_back(file);
|
||||||
@ -567,22 +567,18 @@ void InstanceImportTask::processModrinth()
|
|||||||
for (auto it = dependencies.begin(), end = dependencies.end(); it != end; ++it) {
|
for (auto it = dependencies.begin(), end = dependencies.end(); it != end; ++it) {
|
||||||
QString name = it.key();
|
QString name = it.key();
|
||||||
if (name == "minecraft") {
|
if (name == "minecraft") {
|
||||||
if (!minecraftVersion.isEmpty())
|
|
||||||
throw JSONValidationError("Duplicate Minecraft version");
|
|
||||||
minecraftVersion = Json::requireString(*it, "Minecraft version");
|
minecraftVersion = Json::requireString(*it, "Minecraft version");
|
||||||
} else if (name == "fabric-loader") {
|
}
|
||||||
if (!fabricVersion.isEmpty())
|
else if (name == "fabric-loader") {
|
||||||
throw JSONValidationError("Duplicate Fabric Loader version");
|
|
||||||
fabricVersion = Json::requireString(*it, "Fabric Loader version");
|
fabricVersion = Json::requireString(*it, "Fabric Loader version");
|
||||||
} else if (name == "quilt-loader") {
|
}
|
||||||
if (!quiltVersion.isEmpty())
|
else if (name == "quilt-loader") {
|
||||||
throw JSONValidationError("Duplicate Quilt Loader version");
|
|
||||||
quiltVersion = Json::requireString(*it, "Quilt Loader version");
|
quiltVersion = Json::requireString(*it, "Quilt Loader version");
|
||||||
} else if (name == "forge") {
|
}
|
||||||
if (!forgeVersion.isEmpty())
|
else if (name == "forge") {
|
||||||
throw JSONValidationError("Duplicate Forge version");
|
|
||||||
forgeVersion = Json::requireString(*it, "Forge version");
|
forgeVersion = Json::requireString(*it, "Forge version");
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
throw JSONValidationError("Unknown dependency type: " + name);
|
throw JSONValidationError("Unknown dependency type: " + name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -594,6 +590,7 @@ void InstanceImportTask::processModrinth()
|
|||||||
emitFailed(tr("Could not understand pack index:\n") + e.cause());
|
emitFailed(tr("Could not understand pack index:\n") + e.cause());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString overridePath = FS::PathCombine(m_stagingPath, "overrides");
|
QString overridePath = FS::PathCombine(m_stagingPath, "overrides");
|
||||||
if (QFile::exists(overridePath)) {
|
if (QFile::exists(overridePath)) {
|
||||||
QString mcPath = FS::PathCombine(m_stagingPath, ".minecraft");
|
QString mcPath = FS::PathCombine(m_stagingPath, ".minecraft");
|
||||||
|
@ -93,7 +93,7 @@ void loadIndexedVersions(Modpack& pack, QJsonDocument& doc)
|
|||||||
pack.versionsLoaded = true;
|
pack.versionsLoaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto validadeDownloadUrl(QUrl url) -> bool
|
auto validateDownloadUrl(QUrl url) -> bool
|
||||||
{
|
{
|
||||||
auto domain = url.host();
|
auto domain = url.host();
|
||||||
if(domain == "cdn.modrinth.com")
|
if(domain == "cdn.modrinth.com")
|
||||||
@ -139,7 +139,7 @@ auto loadIndexedVersion(QJsonObject &obj) -> ModpackVersion
|
|||||||
|
|
||||||
auto url = Json::requireString(parent, "url");
|
auto url = Json::requireString(parent, "url");
|
||||||
|
|
||||||
if(!validadeDownloadUrl(url))
|
if(!validateDownloadUrl(url))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
file.download_url = url;
|
file.download_url = url;
|
||||||
|
@ -99,7 +99,7 @@ void loadIndexedInfo(Modpack&, QJsonObject&);
|
|||||||
void loadIndexedVersions(Modpack&, QJsonDocument&);
|
void loadIndexedVersions(Modpack&, QJsonDocument&);
|
||||||
auto loadIndexedVersion(QJsonObject&) -> ModpackVersion;
|
auto loadIndexedVersion(QJsonObject&) -> ModpackVersion;
|
||||||
|
|
||||||
auto validadeDownloadUrl(QUrl) -> bool;
|
auto validateDownloadUrl(QUrl) -> bool;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,7 +195,6 @@ void ModrinthPage::onSelectionChanged(QModelIndex first, QModelIndex second)
|
|||||||
ui->versionSelectionBox->addItem(version.version, QVariant(version.id));
|
ui->versionSelectionBox->addItem(version.version, QVariant(version.id));
|
||||||
}
|
}
|
||||||
|
|
||||||
updateVersionsUI();
|
|
||||||
suggestCurrent();
|
suggestCurrent();
|
||||||
});
|
});
|
||||||
QObject::connect(netJob, &NetJob::finished, this, [response, netJob] {
|
QObject::connect(netJob, &NetJob::finished, this, [response, netJob] {
|
||||||
@ -233,11 +232,6 @@ void ModrinthPage::updateUI()
|
|||||||
ui->packDescription->setHtml(text + current.description);
|
ui->packDescription->setHtml(text + current.description);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModrinthPage::updateVersionsUI()
|
|
||||||
{
|
|
||||||
// idk
|
|
||||||
}
|
|
||||||
|
|
||||||
void ModrinthPage::suggestCurrent()
|
void ModrinthPage::suggestCurrent()
|
||||||
{
|
{
|
||||||
if (!isOpened) {
|
if (!isOpened) {
|
||||||
|
@ -71,7 +71,6 @@ class ModrinthPage : public QWidget, public BasePage {
|
|||||||
void suggestCurrent();
|
void suggestCurrent();
|
||||||
|
|
||||||
void updateUI();
|
void updateUI();
|
||||||
void updateVersionsUI();
|
|
||||||
|
|
||||||
void retranslate() override;
|
void retranslate() override;
|
||||||
void openedImpl() override;
|
void openedImpl() override;
|
||||||
|
Loading…
Reference in New Issue
Block a user