diff options
author | flow <thiagodonato300@gmail.com> | 2022-05-14 22:12:51 -0300 |
---|---|---|
committer | flow <thiagodonato300@gmail.com> | 2022-05-14 22:50:04 -0300 |
commit | 4745ed28186f46de60de155826c8f2bfb54f45cb (patch) | |
tree | 8f43ab1f58a6b0fe35bdc472aae0fa9342e69be0 /launcher/modplatform | |
parent | 49de5d9b07c8e05681ef9d485ccfd3d8e4bca784 (diff) | |
download | PrismLauncher-4745ed28186f46de60de155826c8f2bfb54f45cb.tar.gz PrismLauncher-4745ed28186f46de60de155826c8f2bfb54f45cb.tar.bz2 PrismLauncher-4745ed28186f46de60de155826c8f2bfb54f45cb.zip |
fix: choose valid download url even if it's not the primary one
It seems to be possible to have modpack versions that have to primary
file. In those cases, we pick a valid one "at random".
Diffstat (limited to 'launcher/modplatform')
-rw-r--r-- | launcher/modplatform/modrinth/ModrinthPackManifest.cpp | 14 | ||||
-rw-r--r-- | launcher/modplatform/modrinth/ModrinthPackManifest.h | 4 |
2 files changed, 13 insertions, 5 deletions
diff --git a/launcher/modplatform/modrinth/ModrinthPackManifest.cpp b/launcher/modplatform/modrinth/ModrinthPackManifest.cpp index 4b8a9a9b..88ca808a 100644 --- a/launcher/modplatform/modrinth/ModrinthPackManifest.cpp +++ b/launcher/modplatform/modrinth/ModrinthPackManifest.cpp @@ -81,15 +81,23 @@ auto loadIndexedVersion(QJsonObject &obj) -> ModpackVersion auto files = Json::requireArray(obj, "files"); + qWarning() << files; + for (auto file_iter : files) { File indexed_file; auto parent = Json::requireObject(file_iter); - if (!Json::ensureBoolean(parent, "primary", false)) { - continue; + auto is_primary = Json::ensureBoolean(parent, "primary", false); + if (!is_primary) { + auto filename = Json::ensureString(parent, "filename"); + // Checking suffix here is fine because it's the response from Modrinth, + // so one would assume it will always be in English. + if(!filename.endsWith("mrpack") && !filename.endsWith("zip")) + continue; } file.download_url = Json::requireString(parent, "url"); - break; + if(is_primary) + break; } if(file.download_url.isEmpty()) diff --git a/launcher/modplatform/modrinth/ModrinthPackManifest.h b/launcher/modplatform/modrinth/ModrinthPackManifest.h index aaaacf2c..585f692a 100644 --- a/launcher/modplatform/modrinth/ModrinthPackManifest.h +++ b/launcher/modplatform/modrinth/ModrinthPackManifest.h @@ -79,5 +79,5 @@ auto loadIndexedVersion(QJsonObject&) -> ModpackVersion; } -Q_DECLARE_METATYPE(Modrinth::Modpack); -Q_DECLARE_METATYPE(Modrinth::ModpackVersion); +Q_DECLARE_METATYPE(Modrinth::Modpack) +Q_DECLARE_METATYPE(Modrinth::ModpackVersion) |