fix: implement PR suggestions
Some stylistic changes, and get hashes from the mod providers when building the metadata.
This commit is contained in:
@ -8,7 +8,7 @@
|
||||
|
||||
namespace ModPlatform {
|
||||
|
||||
enum class Provider{
|
||||
enum class Provider {
|
||||
MODRINTH,
|
||||
FLAME
|
||||
};
|
||||
@ -33,6 +33,7 @@ struct IndexedVersion {
|
||||
QString date;
|
||||
QString fileName;
|
||||
QVector<QString> loaders = {};
|
||||
QString hash;
|
||||
};
|
||||
|
||||
struct IndexedPack {
|
||||
|
@ -6,6 +6,8 @@
|
||||
#include "modplatform/flame/FlameAPI.h"
|
||||
#include "net/NetJob.h"
|
||||
|
||||
static ModPlatform::ProviderCapabilities ProviderCaps;
|
||||
|
||||
void FlameMod::loadIndexedPack(ModPlatform::IndexedPack& pack, QJsonObject& obj)
|
||||
{
|
||||
pack.addonId = Json::requireInteger(obj, "id");
|
||||
@ -60,6 +62,12 @@ void FlameMod::loadIndexedPackVersions(ModPlatform::IndexedPack& pack,
|
||||
file.downloadUrl = Json::requireString(obj, "downloadUrl");
|
||||
file.fileName = Json::requireString(obj, "fileName");
|
||||
|
||||
auto hash_list = Json::ensureArray(obj, "hashes");
|
||||
if(!hash_list.isEmpty()){
|
||||
if(hash_list.contains(ProviderCaps.hashType(ModPlatform::Provider::FLAME)))
|
||||
file.hash = Json::requireString(hash_list, "value");
|
||||
}
|
||||
|
||||
unsortedVersions.append(file);
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "net/NetJob.h"
|
||||
|
||||
static ModrinthAPI api;
|
||||
static ModPlatform::ProviderCapabilities ProviderCaps;
|
||||
|
||||
void Modrinth::loadIndexedPack(ModPlatform::IndexedPack& pack, QJsonObject& obj)
|
||||
{
|
||||
@ -95,6 +96,9 @@ void Modrinth::loadIndexedPackVersions(ModPlatform::IndexedPack& pack,
|
||||
if (parent.contains("url")) {
|
||||
file.downloadUrl = Json::requireString(parent, "url");
|
||||
file.fileName = Json::requireString(parent, "filename");
|
||||
auto hash_list = Json::requireObject(parent, "hashes");
|
||||
if(hash_list.contains(ProviderCaps.hashType(ModPlatform::Provider::MODRINTH)))
|
||||
file.hash = Json::requireString(hash_list, ProviderCaps.hashType(ModPlatform::Provider::MODRINTH));
|
||||
|
||||
unsortedVersions.append(file);
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ auto V1::createModFormat(QDir& index_dir, ModPlatform::IndexedPack& mod_pack, Mo
|
||||
|
||||
mod.url = mod_version.downloadUrl;
|
||||
mod.hash_format = ProviderCaps.hashType(mod_pack.provider);
|
||||
mod.hash = ""; // FIXME
|
||||
mod.hash = mod_version.hash;
|
||||
|
||||
mod.provider = mod_pack.provider;
|
||||
mod.file_id = mod_pack.addonId;
|
||||
|
Reference in New Issue
Block a user