From 5f75e531e61e1f2cb5d602e084e9a0ddd1c85a5c Mon Sep 17 00:00:00 2001 From: flow Date: Mon, 20 Jun 2022 08:55:35 -0300 Subject: [PATCH] fix: handling around disabled mods Don't update disabled mods to prevent mod duplication. Also, chop filename in the metadata with a '.disabled'. Signed-off-by: flow --- launcher/modplatform/EnsureMetadataTask.cpp | 4 ++++ launcher/modplatform/flame/FlameCheckUpdate.cpp | 5 +++++ launcher/modplatform/modrinth/ModrinthCheckUpdate.cpp | 5 +++++ launcher/ui/dialogs/ModUpdateDialog.cpp | 10 +++++++--- launcher/ui/dialogs/ModUpdateDialog.h | 2 +- 5 files changed, 22 insertions(+), 4 deletions(-) diff --git a/launcher/modplatform/EnsureMetadataTask.cpp b/launcher/modplatform/EnsureMetadataTask.cpp index cf4e55b9..19e44ce0 100644 --- a/launcher/modplatform/EnsureMetadataTask.cpp +++ b/launcher/modplatform/EnsureMetadataTask.cpp @@ -455,6 +455,8 @@ void EnsureMetadataTask::modrinthCallback(ModPlatform::IndexedPack& pack, ModPla { // Prevent file name mismatch ver.fileName = mod.fileinfo().fileName(); + if (ver.fileName.endsWith(".disabled")) + ver.fileName.chop(9); QDir tmp_index_dir(m_index_dir); @@ -487,6 +489,8 @@ void EnsureMetadataTask::flameCallback(ModPlatform::IndexedPack& pack, ModPlatfo try { // Prevent file name mismatch ver.fileName = mod.fileinfo().fileName(); + if (ver.fileName.endsWith(".disabled")) + ver.fileName.chop(9); QDir tmp_index_dir(m_index_dir); diff --git a/launcher/modplatform/flame/FlameCheckUpdate.cpp b/launcher/modplatform/flame/FlameCheckUpdate.cpp index 3658bf8d..be12dee3 100644 --- a/launcher/modplatform/flame/FlameCheckUpdate.cpp +++ b/launcher/modplatform/flame/FlameCheckUpdate.cpp @@ -118,6 +118,11 @@ void FlameCheckUpdate::executeTask() int i = 0; for (auto mod : m_mods) { + if (!mod.enabled()) { + emit checkFailed(mod, tr("Disabled mods won't be updated, to prevent mod duplication issues!")); + continue; + } + setStatus(tr("Getting API response from CurseForge for '%1'").arg(mod.name())); setProgress(i++, m_mods.size()); diff --git a/launcher/modplatform/modrinth/ModrinthCheckUpdate.cpp b/launcher/modplatform/modrinth/ModrinthCheckUpdate.cpp index 78275cf0..5d936fec 100644 --- a/launcher/modplatform/modrinth/ModrinthCheckUpdate.cpp +++ b/launcher/modplatform/modrinth/ModrinthCheckUpdate.cpp @@ -33,6 +33,11 @@ void ModrinthCheckUpdate::executeTask() QStringList hashes; auto best_hash_type = ProviderCaps.hashType(ModPlatform::Provider::MODRINTH).first(); for (auto mod : m_mods) { + if (!mod.enabled()) { + emit checkFailed(mod, tr("Disabled mods won't be updated, to prevent mod duplication issues!")); + continue; + } + auto hash = mod.metadata()->hash; // Sadly the API can only handle one hash type per call, se we diff --git a/launcher/ui/dialogs/ModUpdateDialog.cpp b/launcher/ui/dialogs/ModUpdateDialog.cpp index 7584621a..2e1fbb08 100644 --- a/launcher/ui/dialogs/ModUpdateDialog.cpp +++ b/launcher/ui/dialogs/ModUpdateDialog.cpp @@ -62,8 +62,10 @@ void ModUpdateDialog::checkCandidates() // Report failed metadata generation if (!m_failed_metadata.empty()) { QString text; - for (const auto& mod : m_failed_metadata) { - text += tr("Mod name: %1
File name: %2

").arg(mod.name(), mod.fileinfo().fileName()); + for (const auto& failed : m_failed_metadata) { + const auto& mod = std::get<0>(failed); + const auto& reason = std::get<1>(failed); + text += tr("Mod name: %1
File name: %2
Reason: %3

").arg(mod.name(), mod.fileinfo().fileName(), reason); } ScrollMessageBox message_dialog(m_parent, tr("Metadata generation failed"), @@ -316,7 +318,9 @@ void ModUpdateDialog::onMetadataFailed(Mod& mod, bool try_others, ModPlatform::P m_second_try_metadata->addTask(task); } else { - m_failed_metadata.push_back(mod); + QString reason { tr("Didn't find a valid version on the selected mod provider(s)") }; + + m_failed_metadata.emplace_back(mod, reason); } } diff --git a/launcher/ui/dialogs/ModUpdateDialog.h b/launcher/ui/dialogs/ModUpdateDialog.h index f40fc594..336fbba2 100644 --- a/launcher/ui/dialogs/ModUpdateDialog.h +++ b/launcher/ui/dialogs/ModUpdateDialog.h @@ -50,7 +50,7 @@ class ModUpdateDialog final : public ReviewMessageBox { std::list m_flame_to_update; SequentialTask* m_second_try_metadata; - std::list m_failed_metadata; + std::list> m_failed_metadata; std::list> m_failed_check_update; QHash m_tasks;