validate metadata on launch

Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
Trial97
2024-06-17 01:33:11 +03:00
parent 4aa2e5b85d
commit 2af6902b42
30 changed files with 253 additions and 215 deletions

View File

@ -93,9 +93,9 @@ static LoadResult loadComponent(ComponentPtr component, Task::Ptr& loadTask, Net
component->m_loaded = true;
result = LoadResult::LoadedLocal;
} else {
metaVersion->load(netmode);
loadTask = metaVersion->getCurrentTask();
if (loadTask)
loadTask = APPLICATION->metadataIndex()->loadVersion(component->m_uid, component->m_version, netmode);
loadTask->start();
if (netmode == Net::Mode::Online)
result = LoadResult::RequiresRemote;
else if (metaVersion->isLoaded())
result = LoadResult::LoadedLocal;
@ -133,21 +133,6 @@ 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()) {
qDebug() << "Index is already loaded";
return LoadResult::LoadedLocal;
}
APPLICATION->metadataIndex()->load(netmode);
loadTask = APPLICATION->metadataIndex()->getCurrentTask();
if (loadTask) {
return LoadResult::RequiresRemote;
}
// FIXME: this is assuming the load succeeded... did it really?
return LoadResult::LoadedLocal;
}
} // namespace
void ComponentUpdateTask::loadComponents()
@ -156,23 +141,8 @@ void ComponentUpdateTask::loadComponents()
size_t taskIndex = 0;
size_t componentIndex = 0;
d->remoteLoadSuccessful = true;
// load the main index (it is needed to determine if components can revert)
{
// FIXME: tear out as a method? or lambda?
Task::Ptr indexLoadTask;
auto singleResult = loadIndex(indexLoadTask, d->netmode);
result = composeLoadResult(result, singleResult);
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")); });
taskIndex++;
}
}
m_load_tasks.clear();
// load all the components OR their lists...
for (auto component : d->m_list->d->components) {
Task::Ptr loadTask;
@ -205,6 +175,7 @@ void ComponentUpdateTask::loadComponents()
}
result = composeLoadResult(result, singleResult);
if (loadTask) {
m_load_tasks.append(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); });