@ -1,16 +1,16 @@
|
||||
#include "ComponentUpdateTask.h"
|
||||
|
||||
#include "PackProfile_p.h"
|
||||
#include "PackProfile.h"
|
||||
#include "Component.h"
|
||||
#include "meta/Index.h"
|
||||
#include "meta/VersionList.h"
|
||||
#include "meta/Version.h"
|
||||
#include "ComponentUpdateTask_p.h"
|
||||
#include "cassert"
|
||||
#include "Version.h"
|
||||
#include "net/Mode.h"
|
||||
#include "OneSixVersionFormat.h"
|
||||
#include "PackProfile.h"
|
||||
#include "PackProfile_p.h"
|
||||
#include "Version.h"
|
||||
#include "cassert"
|
||||
#include "meta/Index.h"
|
||||
#include "meta/Version.h"
|
||||
#include "meta/VersionList.h"
|
||||
#include "net/Mode.h"
|
||||
|
||||
#include "Application.h"
|
||||
|
||||
@ -32,8 +32,7 @@
|
||||
* If the component list changes, start over.
|
||||
*/
|
||||
|
||||
ComponentUpdateTask::ComponentUpdateTask(Mode mode, Net::Mode netmode, PackProfile* list, QObject* parent)
|
||||
: Task(parent)
|
||||
ComponentUpdateTask::ComponentUpdateTask(Mode mode, Net::Mode netmode, PackProfile* list, QObject* parent) : Task(parent)
|
||||
{
|
||||
d.reset(new ComponentUpdateTaskData);
|
||||
d->m_list = list;
|
||||
@ -41,9 +40,7 @@ ComponentUpdateTask::ComponentUpdateTask(Mode mode, Net::Mode netmode, PackProfi
|
||||
d->netmode = netmode;
|
||||
}
|
||||
|
||||
ComponentUpdateTask::~ComponentUpdateTask()
|
||||
{
|
||||
}
|
||||
ComponentUpdateTask::~ComponentUpdateTask() {}
|
||||
|
||||
void ComponentUpdateTask::executeTask()
|
||||
{
|
||||
@ -51,19 +48,12 @@ void ComponentUpdateTask::executeTask()
|
||||
loadComponents();
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
enum class LoadResult
|
||||
{
|
||||
LoadedLocal,
|
||||
RequiresRemote,
|
||||
Failed
|
||||
};
|
||||
namespace {
|
||||
enum class LoadResult { LoadedLocal, RequiresRemote, Failed };
|
||||
|
||||
LoadResult composeLoadResult(LoadResult a, LoadResult b)
|
||||
{
|
||||
if (a < b)
|
||||
{
|
||||
if (a < b) {
|
||||
return b;
|
||||
}
|
||||
return a;
|
||||
@ -71,28 +61,24 @@ LoadResult composeLoadResult(LoadResult a, LoadResult b)
|
||||
|
||||
static LoadResult loadComponent(ComponentPtr component, Task::Ptr& loadTask, Net::Mode netmode)
|
||||
{
|
||||
if(component->m_loaded)
|
||||
{
|
||||
if (component->m_loaded) {
|
||||
qDebug() << component->getName() << "is already loaded";
|
||||
return LoadResult::LoadedLocal;
|
||||
}
|
||||
|
||||
LoadResult result = LoadResult::Failed;
|
||||
auto customPatchFilename = component->getFilename();
|
||||
if(QFile::exists(customPatchFilename))
|
||||
{
|
||||
if (QFile::exists(customPatchFilename)) {
|
||||
// if local file exists...
|
||||
|
||||
// check for uid problems inside...
|
||||
bool fileChanged = false;
|
||||
auto file = ProfileUtils::parseJsonFile(QFileInfo(customPatchFilename), false);
|
||||
if(file->uid != component->m_uid)
|
||||
{
|
||||
if (file->uid != component->m_uid) {
|
||||
file->uid = component->m_uid;
|
||||
fileChanged = true;
|
||||
}
|
||||
if(fileChanged)
|
||||
{
|
||||
if (fileChanged) {
|
||||
// FIXME: @QUALITY do not ignore return value
|
||||
ProfileUtils::saveJsonFile(OneSixVersionFormat::versionFileToJson(file), customPatchFilename);
|
||||
}
|
||||
@ -100,21 +86,16 @@ static LoadResult loadComponent(ComponentPtr component, Task::Ptr& loadTask, Net
|
||||
component->m_file = file;
|
||||
component->m_loaded = true;
|
||||
result = LoadResult::LoadedLocal;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
auto metaVersion = APPLICATION->metadataIndex()->get(component->m_uid, component->m_version);
|
||||
component->m_metaVersion = metaVersion;
|
||||
if(metaVersion->isLoaded())
|
||||
{
|
||||
if (metaVersion->isLoaded()) {
|
||||
component->m_loaded = true;
|
||||
result = LoadResult::LoadedLocal;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
metaVersion->load(netmode);
|
||||
loadTask = metaVersion->getCurrentTask();
|
||||
if(loadTask)
|
||||
if (loadTask)
|
||||
result = LoadResult::RequiresRemote;
|
||||
else if (metaVersion->isLoaded())
|
||||
result = LoadResult::LoadedLocal;
|
||||
@ -155,21 +136,19 @@ static LoadResult loadPackProfile(ComponentPtr component, Task::Ptr& loadTask, N
|
||||
static LoadResult loadIndex(Task::Ptr& loadTask, Net::Mode netmode)
|
||||
{
|
||||
// FIXME: DECIDE. do we want to run the update task anyway?
|
||||
if(APPLICATION->metadataIndex()->isLoaded())
|
||||
{
|
||||
if (APPLICATION->metadataIndex()->isLoaded()) {
|
||||
qDebug() << "Index is already loaded";
|
||||
return LoadResult::LoadedLocal;
|
||||
}
|
||||
APPLICATION->metadataIndex()->load(netmode);
|
||||
loadTask = APPLICATION->metadataIndex()->getCurrentTask();
|
||||
if(loadTask)
|
||||
{
|
||||
if (loadTask) {
|
||||
return LoadResult::RequiresRemote;
|
||||
}
|
||||
// FIXME: this is assuming the load succeeded... did it really?
|
||||
return LoadResult::LoadedLocal;
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void ComponentUpdateTask::loadComponents()
|
||||
{
|
||||
@ -183,34 +162,24 @@ void ComponentUpdateTask::loadComponents()
|
||||
Task::Ptr indexLoadTask;
|
||||
auto singleResult = loadIndex(indexLoadTask, d->netmode);
|
||||
result = composeLoadResult(result, singleResult);
|
||||
if(indexLoadTask)
|
||||
{
|
||||
if (indexLoadTask) {
|
||||
qDebug() << "Remote loading is being run for metadata index";
|
||||
RemoteLoadStatus status;
|
||||
status.type = RemoteLoadStatus::Type::Index;
|
||||
d->remoteLoadStatusList.append(status);
|
||||
connect(indexLoadTask.get(), &Task::succeeded, [=]()
|
||||
{
|
||||
remoteLoadSucceeded(taskIndex);
|
||||
});
|
||||
connect(indexLoadTask.get(), &Task::failed, [=](const QString & error)
|
||||
{
|
||||
remoteLoadFailed(taskIndex, error);
|
||||
});
|
||||
connect(indexLoadTask.get(), &Task::aborted, [=]()
|
||||
{
|
||||
remoteLoadFailed(taskIndex, tr("Aborted"));
|
||||
});
|
||||
connect(indexLoadTask.get(), &Task::succeeded, [=]() { remoteLoadSucceeded(taskIndex); });
|
||||
connect(indexLoadTask.get(), &Task::failed, [=](const QString& error) { remoteLoadFailed(taskIndex, error); });
|
||||
connect(indexLoadTask.get(), &Task::aborted, [=]() { remoteLoadFailed(taskIndex, tr("Aborted")); });
|
||||
taskIndex++;
|
||||
}
|
||||
}
|
||||
// load all the components OR their lists...
|
||||
for (auto component: d->m_list->d->components)
|
||||
{
|
||||
for (auto component : d->m_list->d->components) {
|
||||
Task::Ptr loadTask;
|
||||
LoadResult singleResult;
|
||||
RemoteLoadStatus::Type loadType;
|
||||
// FIXME: to do this right, we need to load the lists and decide on which versions to use during dependency resolution. For now, ignore all that...
|
||||
// FIXME: to do this right, we need to load the lists and decide on which versions to use during dependency resolution. For now,
|
||||
// ignore all that...
|
||||
#if 0
|
||||
switch(d->mode)
|
||||
{
|
||||
@ -231,26 +200,15 @@ void ComponentUpdateTask::loadComponents()
|
||||
singleResult = loadComponent(component, loadTask, d->netmode);
|
||||
loadType = RemoteLoadStatus::Type::Version;
|
||||
#endif
|
||||
if(singleResult == LoadResult::LoadedLocal)
|
||||
{
|
||||
if (singleResult == LoadResult::LoadedLocal) {
|
||||
component->updateCachedData();
|
||||
}
|
||||
result = composeLoadResult(result, singleResult);
|
||||
if (loadTask)
|
||||
{
|
||||
if (loadTask) {
|
||||
qDebug() << "Remote loading is being run for" << component->getName();
|
||||
connect(loadTask.get(), &Task::succeeded, [=]()
|
||||
{
|
||||
remoteLoadSucceeded(taskIndex);
|
||||
});
|
||||
connect(loadTask.get(), &Task::failed, [=](const QString & error)
|
||||
{
|
||||
remoteLoadFailed(taskIndex, error);
|
||||
});
|
||||
connect(loadTask.get(), &Task::aborted, [=]()
|
||||
{
|
||||
remoteLoadFailed(taskIndex, tr("Aborted"));
|
||||
});
|
||||
connect(loadTask.get(), &Task::succeeded, [=]() { remoteLoadSucceeded(taskIndex); });
|
||||
connect(loadTask.get(), &Task::failed, [=](const QString& error) { remoteLoadFailed(taskIndex, error); });
|
||||
connect(loadTask.get(), &Task::aborted, [=]() { remoteLoadFailed(taskIndex, tr("Aborted")); });
|
||||
RemoteLoadStatus status;
|
||||
status.type = loadType;
|
||||
status.PackProfileIndex = componentIndex;
|
||||
@ -260,95 +218,73 @@ void ComponentUpdateTask::loadComponents()
|
||||
componentIndex++;
|
||||
}
|
||||
d->remoteTasksInProgress = taskIndex;
|
||||
switch(result)
|
||||
{
|
||||
case LoadResult::LoadedLocal:
|
||||
{
|
||||
switch (result) {
|
||||
case LoadResult::LoadedLocal: {
|
||||
// Everything got loaded. Advance to dependency resolution.
|
||||
resolveDependencies(d->mode == Mode::Launch || d->netmode == Net::Mode::Offline);
|
||||
break;
|
||||
}
|
||||
case LoadResult::RequiresRemote:
|
||||
{
|
||||
case LoadResult::RequiresRemote: {
|
||||
// we wait for signals.
|
||||
break;
|
||||
}
|
||||
case LoadResult::Failed:
|
||||
{
|
||||
case LoadResult::Failed: {
|
||||
emitFailed(tr("Some component metadata load tasks failed."));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
struct RequireEx : public Meta::Require
|
||||
{
|
||||
size_t indexOfFirstDependee = 0;
|
||||
};
|
||||
struct RequireCompositionResult
|
||||
{
|
||||
bool ok;
|
||||
RequireEx outcome;
|
||||
};
|
||||
using RequireExSet = std::set<RequireEx>;
|
||||
}
|
||||
namespace {
|
||||
struct RequireEx : public Meta::Require {
|
||||
size_t indexOfFirstDependee = 0;
|
||||
};
|
||||
struct RequireCompositionResult {
|
||||
bool ok;
|
||||
RequireEx outcome;
|
||||
};
|
||||
using RequireExSet = std::set<RequireEx>;
|
||||
} // namespace
|
||||
|
||||
static RequireCompositionResult composeRequirement(const RequireEx & a, const RequireEx & b)
|
||||
static RequireCompositionResult composeRequirement(const RequireEx& a, const RequireEx& b)
|
||||
{
|
||||
assert(a.uid == b.uid);
|
||||
RequireEx out;
|
||||
out.uid = a.uid;
|
||||
out.indexOfFirstDependee = std::min(a.indexOfFirstDependee, b.indexOfFirstDependee);
|
||||
if(a.equalsVersion.isEmpty())
|
||||
{
|
||||
if (a.equalsVersion.isEmpty()) {
|
||||
out.equalsVersion = b.equalsVersion;
|
||||
}
|
||||
else if (b.equalsVersion.isEmpty())
|
||||
{
|
||||
} else if (b.equalsVersion.isEmpty()) {
|
||||
out.equalsVersion = a.equalsVersion;
|
||||
}
|
||||
else if (a.equalsVersion == b.equalsVersion)
|
||||
{
|
||||
} else if (a.equalsVersion == b.equalsVersion) {
|
||||
out.equalsVersion = a.equalsVersion;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// FIXME: mark error as explicit version conflict
|
||||
return {false, out};
|
||||
return { false, out };
|
||||
}
|
||||
|
||||
if(a.suggests.isEmpty())
|
||||
{
|
||||
if (a.suggests.isEmpty()) {
|
||||
out.suggests = b.suggests;
|
||||
}
|
||||
else if (b.suggests.isEmpty())
|
||||
{
|
||||
} else if (b.suggests.isEmpty()) {
|
||||
out.suggests = a.suggests;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
Version aVer(a.suggests);
|
||||
Version bVer(b.suggests);
|
||||
out.suggests = (aVer < bVer ? b.suggests : a.suggests);
|
||||
}
|
||||
return {true, out};
|
||||
return { true, out };
|
||||
}
|
||||
|
||||
// gather the requirements from all components, finding any obvious conflicts
|
||||
static bool gatherRequirementsFromComponents(const ComponentContainer & input, RequireExSet & output)
|
||||
static bool gatherRequirementsFromComponents(const ComponentContainer& input, RequireExSet& output)
|
||||
{
|
||||
bool succeeded = true;
|
||||
size_t componentNum = 0;
|
||||
for(auto component: input)
|
||||
{
|
||||
auto &componentRequires = component->m_cachedRequires;
|
||||
for(const auto & componentRequire: componentRequires)
|
||||
{
|
||||
auto found = std::find_if(output.cbegin(), output.cend(), [componentRequire](const Meta::Require & req){
|
||||
return req.uid == componentRequire.uid;
|
||||
});
|
||||
for (auto component : input) {
|
||||
auto& componentRequires = component->m_cachedRequires;
|
||||
for (const auto& componentRequire : componentRequires) {
|
||||
auto found = std::find_if(output.cbegin(), output.cend(),
|
||||
[componentRequire](const Meta::Require& req) { return req.uid == componentRequire.uid; });
|
||||
|
||||
RequireEx componenRequireEx;
|
||||
componenRequireEx.uid = componentRequire.uid;
|
||||
@ -356,29 +292,18 @@ static bool gatherRequirementsFromComponents(const ComponentContainer & input, R
|
||||
componenRequireEx.equalsVersion = componentRequire.equalsVersion;
|
||||
componenRequireEx.indexOfFirstDependee = componentNum;
|
||||
|
||||
if(found != output.cend())
|
||||
{
|
||||
if (found != output.cend()) {
|
||||
// found... process it further
|
||||
auto result = composeRequirement(componenRequireEx, *found);
|
||||
if(result.ok)
|
||||
{
|
||||
if (result.ok) {
|
||||
output.erase(componenRequireEx);
|
||||
output.insert(result.outcome);
|
||||
}
|
||||
else
|
||||
{
|
||||
qCritical()
|
||||
<< "Conflicting requirements:"
|
||||
<< componentRequire.uid
|
||||
<< "versions:"
|
||||
<< componentRequire.equalsVersion
|
||||
<< ";"
|
||||
<< (*found).equalsVersion;
|
||||
} else {
|
||||
qCritical() << "Conflicting requirements:" << componentRequire.uid << "versions:" << componentRequire.equalsVersion
|
||||
<< ";" << (*found).equalsVersion;
|
||||
}
|
||||
succeeded &= result.ok;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// not found, accumulate
|
||||
output.insert(componenRequireEx);
|
||||
}
|
||||
@ -389,19 +314,17 @@ static bool gatherRequirementsFromComponents(const ComponentContainer & input, R
|
||||
}
|
||||
|
||||
/// Get list of uids that can be trivially removed because nothing is depending on them anymore (and they are installed as deps)
|
||||
static void getTrivialRemovals(const ComponentContainer & components, const RequireExSet & reqs, QStringList &toRemove)
|
||||
static void getTrivialRemovals(const ComponentContainer& components, const RequireExSet& reqs, QStringList& toRemove)
|
||||
{
|
||||
for(const auto & component: components)
|
||||
{
|
||||
if(!component->m_dependencyOnly)
|
||||
for (const auto& component : components) {
|
||||
if (!component->m_dependencyOnly)
|
||||
continue;
|
||||
if(!component->m_cachedVolatile)
|
||||
if (!component->m_cachedVolatile)
|
||||
continue;
|
||||
RequireEx reqNeedle;
|
||||
reqNeedle.uid = component->m_uid;
|
||||
const auto iter = reqs.find(reqNeedle);
|
||||
if(iter == reqs.cend())
|
||||
{
|
||||
if (iter == reqs.cend()) {
|
||||
toRemove.append(component->m_uid);
|
||||
}
|
||||
}
|
||||
@ -415,60 +338,40 @@ static void getTrivialRemovals(const ComponentContainer & components, const Requ
|
||||
* toAdd - set of requirements than mean adding a new component
|
||||
* toChange - set of requirements that mean changing version of an existing component
|
||||
*/
|
||||
static bool getTrivialComponentChanges(const ComponentIndex & index, const RequireExSet & input, RequireExSet & toAdd, RequireExSet & toChange)
|
||||
static bool getTrivialComponentChanges(const ComponentIndex& index, const RequireExSet& input, RequireExSet& toAdd, RequireExSet& toChange)
|
||||
{
|
||||
enum class Decision
|
||||
{
|
||||
Undetermined,
|
||||
Met,
|
||||
Missing,
|
||||
VersionNotSame,
|
||||
LockedVersionNotSame
|
||||
} decision = Decision::Undetermined;
|
||||
enum class Decision { Undetermined, Met, Missing, VersionNotSame, LockedVersionNotSame } decision = Decision::Undetermined;
|
||||
|
||||
QString reqStr;
|
||||
bool succeeded = true;
|
||||
// list the composed requirements and say if they are met or unmet
|
||||
for(auto & req: input)
|
||||
{
|
||||
do
|
||||
{
|
||||
if(req.equalsVersion.isEmpty())
|
||||
{
|
||||
for (auto& req : input) {
|
||||
do {
|
||||
if (req.equalsVersion.isEmpty()) {
|
||||
reqStr = QString("Req: %1").arg(req.uid);
|
||||
if(index.contains(req.uid))
|
||||
{
|
||||
if (index.contains(req.uid)) {
|
||||
decision = Decision::Met;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
toAdd.insert(req);
|
||||
decision = Decision::Missing;
|
||||
}
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
reqStr = QString("Req: %1 == %2").arg(req.uid, req.equalsVersion);
|
||||
const auto & compIter = index.find(req.uid);
|
||||
if(compIter == index.cend())
|
||||
{
|
||||
const auto& compIter = index.find(req.uid);
|
||||
if (compIter == index.cend()) {
|
||||
toAdd.insert(req);
|
||||
decision = Decision::Missing;
|
||||
break;
|
||||
}
|
||||
auto & comp = (*compIter);
|
||||
if(comp->getVersion() != req.equalsVersion)
|
||||
{
|
||||
if(comp->isCustom()) {
|
||||
auto& comp = (*compIter);
|
||||
if (comp->getVersion() != req.equalsVersion) {
|
||||
if (comp->isCustom()) {
|
||||
decision = Decision::LockedVersionNotSame;
|
||||
} else {
|
||||
if(comp->m_dependencyOnly)
|
||||
{
|
||||
if (comp->m_dependencyOnly) {
|
||||
decision = Decision::VersionNotSame;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
decision = Decision::LockedVersionNotSame;
|
||||
}
|
||||
}
|
||||
@ -476,9 +379,8 @@ static bool getTrivialComponentChanges(const ComponentIndex & index, const Requi
|
||||
}
|
||||
decision = Decision::Met;
|
||||
}
|
||||
} while(false);
|
||||
switch(decision)
|
||||
{
|
||||
} while (false);
|
||||
switch (decision) {
|
||||
case Decision::Undetermined:
|
||||
qCritical() << "No decision for" << reqStr;
|
||||
succeeded = false;
|
||||
@ -520,26 +422,22 @@ void ComponentUpdateTask::resolveDependencies(bool checkOnly)
|
||||
*
|
||||
* NOTE: this is a placeholder and should eventually be replaced with something 'serious'
|
||||
*/
|
||||
auto & components = d->m_list->d->components;
|
||||
auto & componentIndex = d->m_list->d->componentIndex;
|
||||
auto& components = d->m_list->d->components;
|
||||
auto& componentIndex = d->m_list->d->componentIndex;
|
||||
|
||||
RequireExSet allRequires;
|
||||
QStringList toRemove;
|
||||
do
|
||||
{
|
||||
do {
|
||||
allRequires.clear();
|
||||
toRemove.clear();
|
||||
if(!gatherRequirementsFromComponents(components, allRequires))
|
||||
{
|
||||
if (!gatherRequirementsFromComponents(components, allRequires)) {
|
||||
emitFailed(tr("Conflicting requirements detected during dependency checking!"));
|
||||
return;
|
||||
}
|
||||
getTrivialRemovals(components, allRequires, toRemove);
|
||||
if(!toRemove.isEmpty())
|
||||
{
|
||||
if (!toRemove.isEmpty()) {
|
||||
qDebug() << "Removing obsolete components...";
|
||||
for(auto & remove : toRemove)
|
||||
{
|
||||
for (auto& remove : toRemove) {
|
||||
qDebug() << "Removing" << remove;
|
||||
d->m_list->remove(remove);
|
||||
}
|
||||
@ -548,69 +446,50 @@ void ComponentUpdateTask::resolveDependencies(bool checkOnly)
|
||||
RequireExSet toAdd;
|
||||
RequireExSet toChange;
|
||||
bool succeeded = getTrivialComponentChanges(componentIndex, allRequires, toAdd, toChange);
|
||||
if(!succeeded)
|
||||
{
|
||||
if (!succeeded) {
|
||||
emitFailed(tr("Instance has conflicting dependencies."));
|
||||
return;
|
||||
}
|
||||
if(checkOnly)
|
||||
{
|
||||
if(toAdd.size() || toChange.size())
|
||||
{
|
||||
if (checkOnly) {
|
||||
if (toAdd.size() || toChange.size()) {
|
||||
emitFailed(tr("Instance has unresolved dependencies while loading/checking for launch."));
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
emitSucceeded();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
bool recursionNeeded = false;
|
||||
if(toAdd.size())
|
||||
{
|
||||
if (toAdd.size()) {
|
||||
// add stuff...
|
||||
for(auto &add: toAdd)
|
||||
{
|
||||
for (auto& add : toAdd) {
|
||||
auto component = makeShared<Component>(d->m_list, add.uid);
|
||||
if(!add.equalsVersion.isEmpty())
|
||||
{
|
||||
if (!add.equalsVersion.isEmpty()) {
|
||||
// exact version
|
||||
qDebug() << "Adding" << add.uid << "version" << add.equalsVersion << "at position" << add.indexOfFirstDependee;
|
||||
component->m_version = add.equalsVersion;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// version needs to be decided
|
||||
qDebug() << "Adding" << add.uid << "at position" << add.indexOfFirstDependee;
|
||||
// ############################################################################################################
|
||||
// HACK HACK HACK HACK FIXME: this is a placeholder for deciding what version to use. For now, it is hardcoded.
|
||||
if(!add.suggests.isEmpty())
|
||||
{
|
||||
// ############################################################################################################
|
||||
// HACK HACK HACK HACK FIXME: this is a placeholder for deciding what version to use. For now, it is hardcoded.
|
||||
if (!add.suggests.isEmpty()) {
|
||||
component->m_version = add.suggests;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(add.uid == "org.lwjgl")
|
||||
{
|
||||
} else {
|
||||
if (add.uid == "org.lwjgl") {
|
||||
component->m_version = "2.9.1";
|
||||
}
|
||||
else if (add.uid == "org.lwjgl3")
|
||||
{
|
||||
} else if (add.uid == "org.lwjgl3") {
|
||||
component->m_version = "3.1.2";
|
||||
}
|
||||
else if (add.uid == "net.fabricmc.intermediary" || add.uid == "org.quiltmc.hashed")
|
||||
{
|
||||
auto minecraft = std::find_if(components.begin(), components.end(), [](ComponentPtr & cmp){
|
||||
return cmp->getID() == "net.minecraft";
|
||||
});
|
||||
if(minecraft != components.end()) {
|
||||
} else if (add.uid == "net.fabricmc.intermediary" || add.uid == "org.quiltmc.hashed") {
|
||||
auto minecraft = std::find_if(components.begin(), components.end(),
|
||||
[](ComponentPtr& cmp) { return cmp->getID() == "net.minecraft"; });
|
||||
if (minecraft != components.end()) {
|
||||
component->m_version = (*minecraft)->getVersion();
|
||||
}
|
||||
}
|
||||
}
|
||||
// HACK HACK HACK HACK FIXME: this is a placeholder for deciding what version to use. For now, it is hardcoded.
|
||||
// ############################################################################################################
|
||||
// HACK HACK HACK HACK FIXME: this is a placeholder for deciding what version to use. For now, it is hardcoded.
|
||||
// ############################################################################################################
|
||||
}
|
||||
component->m_dependencyOnly = true;
|
||||
// FIXME: this should not work directly with the component list
|
||||
@ -619,11 +498,9 @@ void ComponentUpdateTask::resolveDependencies(bool checkOnly)
|
||||
}
|
||||
recursionNeeded = true;
|
||||
}
|
||||
if(toChange.size())
|
||||
{
|
||||
if (toChange.size()) {
|
||||
// change a version of something that exists
|
||||
for(auto &change: toChange)
|
||||
{
|
||||
for (auto& change : toChange) {
|
||||
// FIXME: this should not work directly with the component list
|
||||
qDebug() << "Setting version of " << change.uid << "to" << change.equalsVersion;
|
||||
auto component = componentIndex[change.uid];
|
||||
@ -632,31 +509,26 @@ void ComponentUpdateTask::resolveDependencies(bool checkOnly)
|
||||
recursionNeeded = true;
|
||||
}
|
||||
|
||||
if(recursionNeeded)
|
||||
{
|
||||
if (recursionNeeded) {
|
||||
loadComponents();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
emitSucceeded();
|
||||
}
|
||||
}
|
||||
|
||||
void ComponentUpdateTask::remoteLoadSucceeded(size_t taskIndex)
|
||||
{
|
||||
auto &taskSlot = d->remoteLoadStatusList[taskIndex];
|
||||
if(taskSlot.finished)
|
||||
{
|
||||
auto& taskSlot = d->remoteLoadStatusList[taskIndex];
|
||||
if (taskSlot.finished) {
|
||||
qWarning() << "Got multiple results from remote load task" << taskIndex;
|
||||
return;
|
||||
}
|
||||
qDebug() << "Remote task" << taskIndex << "succeeded";
|
||||
taskSlot.succeeded = false;
|
||||
taskSlot.finished = true;
|
||||
d->remoteTasksInProgress --;
|
||||
d->remoteTasksInProgress--;
|
||||
// update the cached data of the component from the downloaded version file.
|
||||
if (taskSlot.type == RemoteLoadStatus::Type::Version)
|
||||
{
|
||||
if (taskSlot.type == RemoteLoadStatus::Type::Version) {
|
||||
auto component = d->m_list->getComponent(taskSlot.PackProfileIndex);
|
||||
component->m_loaded = true;
|
||||
component->updateCachedData();
|
||||
@ -664,12 +536,10 @@ void ComponentUpdateTask::remoteLoadSucceeded(size_t taskIndex)
|
||||
checkIfAllFinished();
|
||||
}
|
||||
|
||||
|
||||
void ComponentUpdateTask::remoteLoadFailed(size_t taskIndex, const QString& msg)
|
||||
{
|
||||
auto &taskSlot = d->remoteLoadStatusList[taskIndex];
|
||||
if(taskSlot.finished)
|
||||
{
|
||||
auto& taskSlot = d->remoteLoadStatusList[taskIndex];
|
||||
if (taskSlot.finished) {
|
||||
qWarning() << "Got multiple results from remote load task" << taskIndex;
|
||||
return;
|
||||
}
|
||||
@ -678,31 +548,25 @@ void ComponentUpdateTask::remoteLoadFailed(size_t taskIndex, const QString& msg)
|
||||
taskSlot.succeeded = false;
|
||||
taskSlot.finished = true;
|
||||
taskSlot.error = msg;
|
||||
d->remoteTasksInProgress --;
|
||||
d->remoteTasksInProgress--;
|
||||
checkIfAllFinished();
|
||||
}
|
||||
|
||||
void ComponentUpdateTask::checkIfAllFinished()
|
||||
{
|
||||
if(d->remoteTasksInProgress)
|
||||
{
|
||||
if (d->remoteTasksInProgress) {
|
||||
// not yet...
|
||||
return;
|
||||
}
|
||||
if(d->remoteLoadSuccessful)
|
||||
{
|
||||
if (d->remoteLoadSuccessful) {
|
||||
// nothing bad happened... clear the temp load status and proceed with looking at dependencies
|
||||
d->remoteLoadStatusList.clear();
|
||||
resolveDependencies(d->mode == Mode::Launch);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// remote load failed... report error and bail
|
||||
QStringList allErrorsList;
|
||||
for(auto & item: d->remoteLoadStatusList)
|
||||
{
|
||||
if(!item.succeeded)
|
||||
{
|
||||
for (auto& item : d->remoteLoadStatusList) {
|
||||
if (!item.succeeded) {
|
||||
allErrorsList.append(item.error);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user