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 <flowlnlnln@gmail.com>
This commit is contained in:
flow 2022-06-20 08:55:35 -03:00
parent a7648d60ce
commit 5f75e531e6
No known key found for this signature in database
GPG Key ID: 8D0F221F0A59F469
5 changed files with 22 additions and 4 deletions

View File

@ -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);

View File

@ -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());

View File

@ -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

View File

@ -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<br>File name: %2<br><br>").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<br>File name: %2<br>Reason: %3<br><br>").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);
}
}

View File

@ -50,7 +50,7 @@ class ModUpdateDialog final : public ReviewMessageBox {
std::list<Mod> m_flame_to_update;
SequentialTask* m_second_try_metadata;
std::list<Mod> m_failed_metadata;
std::list<std::tuple<Mod, QString>> m_failed_metadata;
std::list<std::tuple<Mod, QString, QUrl>> m_failed_check_update;
QHash<QString, ModDownloadTask*> m_tasks;