Fixed regresion regarding modrinth project_id in dependence array
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
parent
8ad9692daa
commit
6fd729e285
@ -79,28 +79,34 @@ QList<ModPlatform::Dependency> GetModDependenciesTask::getDependenciesForVersion
|
|||||||
if (ver_dep.type != ModPlatform::DependencyType::REQUIRED)
|
if (ver_dep.type != ModPlatform::DependencyType::REQUIRED)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
auto isOnlyVersion = providerName == ModPlatform::ResourceProvider::MODRINTH && ver_dep.addonId.toString().isEmpty();
|
||||||
if (auto dep = std::find_if(c_dependencies.begin(), c_dependencies.end(),
|
if (auto dep = std::find_if(c_dependencies.begin(), c_dependencies.end(),
|
||||||
[&ver_dep](const ModPlatform::Dependency& i) { return i.addonId == ver_dep.addonId; });
|
[&ver_dep, isOnlyVersion](const ModPlatform::Dependency& i) {
|
||||||
|
return isOnlyVersion ? i.version == ver_dep.version : i.addonId == ver_dep.addonId;
|
||||||
|
});
|
||||||
dep != c_dependencies.end())
|
dep != c_dependencies.end())
|
||||||
continue; // check the current dependency list
|
continue; // check the current dependency list
|
||||||
|
|
||||||
if (auto dep = std::find_if(m_selected.begin(), m_selected.end(),
|
if (auto dep = std::find_if(m_selected.begin(), m_selected.end(),
|
||||||
[&ver_dep, providerName](std::shared_ptr<PackDependency> i) {
|
[&ver_dep, providerName, isOnlyVersion](std::shared_ptr<PackDependency> i) {
|
||||||
return i->pack->addonId == ver_dep.addonId && i->pack->provider == providerName;
|
return i->pack->provider == providerName && (isOnlyVersion ? i->version.version == ver_dep.version
|
||||||
|
: i->pack->addonId == ver_dep.addonId);
|
||||||
});
|
});
|
||||||
dep != m_selected.end())
|
dep != m_selected.end())
|
||||||
continue; // check the selected versions
|
continue; // check the selected versions
|
||||||
|
|
||||||
if (auto dep = std::find_if(m_mods.begin(), m_mods.end(),
|
if (auto dep = std::find_if(m_mods.begin(), m_mods.end(),
|
||||||
[&ver_dep, providerName](std::shared_ptr<Metadata::ModStruct> i) {
|
[&ver_dep, providerName, isOnlyVersion](std::shared_ptr<Metadata::ModStruct> i) {
|
||||||
return i->project_id == ver_dep.addonId && i->provider == providerName;
|
return i->provider == providerName &&
|
||||||
|
(isOnlyVersion ? i->file_id == ver_dep.version : i->project_id == ver_dep.addonId);
|
||||||
});
|
});
|
||||||
dep != m_mods.end())
|
dep != m_mods.end())
|
||||||
continue; // check the existing mods
|
continue; // check the existing mods
|
||||||
|
|
||||||
if (auto dep = std::find_if(m_pack_dependencies.begin(), m_pack_dependencies.end(),
|
if (auto dep = std::find_if(m_pack_dependencies.begin(), m_pack_dependencies.end(),
|
||||||
[&ver_dep, providerName](std::shared_ptr<PackDependency> i) {
|
[&ver_dep, providerName, isOnlyVersion](std::shared_ptr<PackDependency> i) {
|
||||||
return i->pack->addonId == ver_dep.addonId && i->pack->provider == providerName;
|
return i->pack->provider == providerName && (isOnlyVersion ? i->version.version == ver_dep.addonId
|
||||||
|
: i->pack->addonId == ver_dep.addonId);
|
||||||
});
|
});
|
||||||
dep != m_pack_dependencies.end()) // check loaded dependencies
|
dep != m_pack_dependencies.end()) // check loaded dependencies
|
||||||
continue;
|
continue;
|
||||||
@ -110,22 +116,11 @@ QList<ModPlatform::Dependency> GetModDependenciesTask::getDependenciesForVersion
|
|||||||
return c_dependencies;
|
return c_dependencies;
|
||||||
};
|
};
|
||||||
|
|
||||||
Task::Ptr GetModDependenciesTask::prepareDependencyTask(const ModPlatform::Dependency& dep,
|
Task::Ptr GetModDependenciesTask::getProjectInfoTask(std::shared_ptr<PackDependency> pDep)
|
||||||
const ModPlatform::ResourceProvider providerName,
|
|
||||||
int level)
|
|
||||||
{
|
{
|
||||||
auto pDep = std::make_shared<PackDependency>();
|
auto provider = pDep->pack->provider == m_flame_provider.name ? m_flame_provider : m_modrinth_provider;
|
||||||
pDep->dependency = dep;
|
|
||||||
pDep->pack = std::make_shared<ModPlatform::IndexedPack>();
|
|
||||||
pDep->pack->addonId = dep.addonId;
|
|
||||||
pDep->pack->provider = providerName;
|
|
||||||
m_pack_dependencies.append(pDep);
|
|
||||||
auto provider = providerName == m_flame_provider.name ? m_flame_provider : m_modrinth_provider;
|
|
||||||
|
|
||||||
auto tasks = makeShared<SequentialTask>(this, QString("DependencyInfo: %1").arg(dep.addonId.toString()));
|
|
||||||
|
|
||||||
auto responseInfo = new QByteArray();
|
auto responseInfo = new QByteArray();
|
||||||
auto info = provider.api->getProject(dep.addonId.toString(), responseInfo);
|
auto info = provider.api->getProject(pDep->pack->addonId.toString(), responseInfo);
|
||||||
QObject::connect(info.get(), &NetJob::succeeded, [responseInfo, provider, pDep] {
|
QObject::connect(info.get(), &NetJob::succeeded, [responseInfo, provider, pDep] {
|
||||||
QJsonParseError parse_error{};
|
QJsonParseError parse_error{};
|
||||||
QJsonDocument doc = QJsonDocument::fromJson(*responseInfo, &parse_error);
|
QJsonDocument doc = QJsonDocument::fromJson(*responseInfo, &parse_error);
|
||||||
@ -144,7 +139,27 @@ Task::Ptr GetModDependenciesTask::prepareDependencyTask(const ModPlatform::Depen
|
|||||||
qWarning() << "Error while reading mod info: " << e.cause();
|
qWarning() << "Error while reading mod info: " << e.cause();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
tasks->addTask(info);
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
Task::Ptr GetModDependenciesTask::prepareDependencyTask(const ModPlatform::Dependency& dep,
|
||||||
|
const ModPlatform::ResourceProvider providerName,
|
||||||
|
int level)
|
||||||
|
{
|
||||||
|
auto pDep = std::make_shared<PackDependency>();
|
||||||
|
pDep->dependency = dep;
|
||||||
|
pDep->pack = std::make_shared<ModPlatform::IndexedPack>();
|
||||||
|
pDep->pack->addonId = dep.addonId;
|
||||||
|
pDep->pack->provider = providerName;
|
||||||
|
m_pack_dependencies.append(pDep);
|
||||||
|
auto provider = providerName == m_flame_provider.name ? m_flame_provider : m_modrinth_provider;
|
||||||
|
|
||||||
|
auto tasks = makeShared<SequentialTask>(
|
||||||
|
this, QString("DependencyInfo: %1").arg(dep.addonId.toString().isEmpty() ? dep.version : dep.addonId.toString()));
|
||||||
|
|
||||||
|
if (!dep.addonId.toString().isEmpty()) {
|
||||||
|
tasks->addTask(getProjectInfoTask(pDep));
|
||||||
|
}
|
||||||
|
|
||||||
ResourceAPI::DependencySearchArgs args = { dep, m_version, m_loaderType };
|
ResourceAPI::DependencySearchArgs args = { dep, m_version, m_loaderType };
|
||||||
ResourceAPI::DependencySearchCallbacks callbacks;
|
ResourceAPI::DependencySearchCallbacks callbacks;
|
||||||
@ -176,6 +191,10 @@ Task::Ptr GetModDependenciesTask::prepareDependencyTask(const ModPlatform::Depen
|
|||||||
qWarning() << "Dependency cycle exeeded";
|
qWarning() << "Dependency cycle exeeded";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (dep.addonId.toString().isEmpty() && !pDep->version.addonId.toString().isEmpty()) {
|
||||||
|
pDep->pack->addonId = pDep->version.addonId;
|
||||||
|
addTask(getProjectInfoTask(pDep));
|
||||||
|
}
|
||||||
for (auto dep : getDependenciesForVersion(pDep->version, provider.name)) {
|
for (auto dep : getDependenciesForVersion(pDep->version, provider.name)) {
|
||||||
addTask(prepareDependencyTask(dep, provider.name, level - 1));
|
addTask(prepareDependencyTask(dep, provider.name, level - 1));
|
||||||
}
|
}
|
||||||
|
@ -68,6 +68,7 @@ class GetModDependenciesTask : public SequentialTask {
|
|||||||
QList<ModPlatform::Dependency> getDependenciesForVersion(const ModPlatform::IndexedVersion&,
|
QList<ModPlatform::Dependency> getDependenciesForVersion(const ModPlatform::IndexedVersion&,
|
||||||
const ModPlatform::ResourceProvider providerName);
|
const ModPlatform::ResourceProvider providerName);
|
||||||
void prepare();
|
void prepare();
|
||||||
|
Task::Ptr getProjectInfoTask(std::shared_ptr<PackDependency> pDep);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<std::shared_ptr<PackDependency>> m_pack_dependencies;
|
QList<std::shared_ptr<PackDependency>> m_pack_dependencies;
|
||||||
|
@ -144,7 +144,7 @@ auto Modrinth::loadIndexedPackVersion(QJsonObject& obj, QString preferred_hash_t
|
|||||||
for (auto d : dependencies) {
|
for (auto d : dependencies) {
|
||||||
auto dep = Json::ensureObject(d);
|
auto dep = Json::ensureObject(d);
|
||||||
ModPlatform::Dependency dependency;
|
ModPlatform::Dependency dependency;
|
||||||
dependency.addonId = Json::requireString(dep, "project_id");
|
dependency.addonId = Json::ensureString(dep, "project_id");
|
||||||
dependency.version = Json::ensureString(dep, "version_id");
|
dependency.version = Json::ensureString(dep, "version_id");
|
||||||
auto depType = Json::requireString(dep, "dependency_type");
|
auto depType = Json::requireString(dep, "dependency_type");
|
||||||
|
|
||||||
|
@ -125,14 +125,22 @@ void ResourceDownloadDialog::connectButtons()
|
|||||||
|
|
||||||
static ModPlatform::ProviderCapabilities ProviderCaps;
|
static ModPlatform::ProviderCapabilities ProviderCaps;
|
||||||
|
|
||||||
QStringList getRequiredBy(QList<ResourceDownloadDialog::DownloadTaskPtr> tasks, QVariant addonId)
|
QStringList getRequiredBy(QList<ResourceDownloadDialog::DownloadTaskPtr> tasks, ResourceDownloadDialog::DownloadTaskPtr pack)
|
||||||
{
|
{
|
||||||
|
auto addonId = pack->getPack()->addonId;
|
||||||
|
auto provider = pack->getPack()->provider;
|
||||||
|
auto version = pack->getVersionID();
|
||||||
auto req = QStringList();
|
auto req = QStringList();
|
||||||
for (auto& task : tasks) {
|
for (auto& task : tasks) {
|
||||||
|
if (provider != task->getPack()->provider)
|
||||||
|
continue;
|
||||||
auto deps = task->getVersion().dependencies;
|
auto deps = task->getVersion().dependencies;
|
||||||
if (auto dep = std::find_if(deps.begin(), deps.end(),
|
if (auto dep = std::find_if(deps.begin(), deps.end(),
|
||||||
[addonId](const ModPlatform::Dependency& d) {
|
[addonId, provider, version](const ModPlatform::Dependency& d) {
|
||||||
return d.addonId == addonId && d.type == ModPlatform::DependencyType::REQUIRED;
|
return d.type == ModPlatform::DependencyType::REQUIRED &&
|
||||||
|
(provider == ModPlatform::ResourceProvider::MODRINTH && d.addonId.toString().isEmpty()
|
||||||
|
? version == d.version
|
||||||
|
: d.addonId == addonId);
|
||||||
});
|
});
|
||||||
dep != deps.end()) {
|
dep != deps.end()) {
|
||||||
req.append(task->getName());
|
req.append(task->getName());
|
||||||
@ -179,7 +187,7 @@ void ResourceDownloadDialog::confirm()
|
|||||||
});
|
});
|
||||||
for (auto& task : selected) {
|
for (auto& task : selected) {
|
||||||
confirm_dialog->appendResource({ task->getName(), task->getFilename(), task->getCustomPath(),
|
confirm_dialog->appendResource({ task->getName(), task->getFilename(), task->getCustomPath(),
|
||||||
ProviderCaps.name(task->getProvider()), getRequiredBy(selected, task->getPack()->addonId) });
|
ProviderCaps.name(task->getProvider()), getRequiredBy(selected, task) });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (confirm_dialog->exec()) {
|
if (confirm_dialog->exec()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user