From 01807fedc9a727629e2207d7b94fd158e74004cd Mon Sep 17 00:00:00 2001 From: Fleeym <61891787+Fleeym@users.noreply.github.com> Date: Wed, 13 Nov 2024 23:19:07 +0200 Subject: [PATCH] fix(ModSource): fix bad unwrap in fetchValidTags --- loader/src/ui/mods/sources/ModSource.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/loader/src/ui/mods/sources/ModSource.cpp b/loader/src/ui/mods/sources/ModSource.cpp index 0860ee73..2234888f 100644 --- a/loader/src/ui/mods/sources/ModSource.cpp +++ b/loader/src/ui/mods/sources/ModSource.cpp @@ -5,6 +5,7 @@ #include #include #include +#include LoadModSuggestionTask loadModSuggestion(LoadProblem const& problem) { // Recommended / suggested are essentially the same thing for the purposes of this @@ -183,19 +184,22 @@ server::ServerRequest> ModSource::fetchValidTags return std::visit(makeVisitor { [](Mod* mod) { return server::getTags().map( - [mod](auto* result) -> Result, server::ServerError> { + [mod](Result, server::ServerError>* result) + -> Result, server::ServerError> { + std::unordered_set finalTags; + auto modTags = mod->getMetadata().getTags(); + if (result->isOk()) { + std::unordered_set fetched = result->unwrap(); // Filter out invalid tags - auto modTags = mod->getMetadata().getTags(); - auto finalTags = std::unordered_set(); - for (auto& tag : modTags) { - if (result->unwrap().contains(tag)) { + for (std::string const& tag : modTags) { + if (fetched.contains(tag)) { finalTags.insert(tag); } } - return Ok(finalTags); } - return Ok(result->unwrap()); + + return Ok(finalTags); }, [](server::ServerProgress* progress) { return *progress;