fix: only allow workarounds for blocked mods from MR when 100% safe
If a version on Modrinth has more than a single mod loader associated, it means that it's possible we might get the wrong file for download, since individual files don't really have this kind of metadata in the API response. So, in such cases, it's best to let the user take care of it instead. Signed-off-by: flow <flowlnlnln@gmail.com>
This commit is contained in:
parent
f229574758
commit
e6e92f2b0e
@ -3,6 +3,8 @@
|
|||||||
#include "Json.h"
|
#include "Json.h"
|
||||||
#include "net/Upload.h"
|
#include "net/Upload.h"
|
||||||
|
|
||||||
|
#include "modplatform/modrinth/ModrinthPackIndex.h"
|
||||||
|
|
||||||
Flame::FileResolvingTask::FileResolvingTask(const shared_qobject_ptr<QNetworkAccessManager>& network, Flame::Manifest& toProcess)
|
Flame::FileResolvingTask::FileResolvingTask(const shared_qobject_ptr<QNetworkAccessManager>& network, Flame::Manifest& toProcess)
|
||||||
: m_network(network), m_toProcess(toProcess)
|
: m_network(network), m_toProcess(toProcess)
|
||||||
{}
|
{}
|
||||||
@ -84,18 +86,21 @@ void Flame::FileResolvingTask::modrinthCheckFinished() {
|
|||||||
delete bytes;
|
delete bytes;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonDocument doc = QJsonDocument::fromJson(*bytes);
|
QJsonDocument doc = QJsonDocument::fromJson(*bytes);
|
||||||
auto obj = doc.object();
|
auto obj = doc.object();
|
||||||
auto array = Json::requireArray(obj,"files");
|
auto file = Modrinth::loadIndexedPackVersion(obj);
|
||||||
for (auto file: array) {
|
|
||||||
auto fileObj = Json::requireObject(file);
|
// If there's more than one mod loader for this version, we can't know for sure
|
||||||
auto primary = Json::requireBoolean(fileObj,"primary");
|
// which file is relative to each loader, so it's best to not use any one and
|
||||||
if (primary) {
|
// let the user download it manually.
|
||||||
out->url = Json::requireUrl(fileObj,"url");
|
if (file.loaders.size() <= 1) {
|
||||||
|
out->url = file.downloadUrl;
|
||||||
qDebug() << "Found alternative on modrinth " << out->fileName;
|
qDebug() << "Found alternative on modrinth " << out->fileName;
|
||||||
break;
|
} else {
|
||||||
}
|
out->resolved = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete bytes;
|
delete bytes;
|
||||||
}
|
}
|
||||||
//copy to an output list and filter out projects found on modrinth
|
//copy to an output list and filter out projects found on modrinth
|
||||||
|
Loading…
x
Reference in New Issue
Block a user