| 53 | } |
| 54 | |
| 55 | void ModUpdateDialog::checkCandidates() |
| 56 | { |
| 57 | // Ensure mods have valid metadata |
| 58 | auto went_well = ensureMetadata(); |
| 59 | if (!went_well) { |
| 60 | m_aborted = true; |
| 61 | return; |
| 62 | } |
| 63 | |
| 64 | // Report failed metadata generation |
| 65 | if (!m_failed_metadata.empty()) { |
| 66 | QString text; |
| 67 | for (const auto& failed : m_failed_metadata) { |
| 68 | const auto& mod = std::get<0>(failed); |
| 69 | const auto& reason = std::get<1>(failed); |
| 70 | text += tr("Mod name: %1<br>File name: %2<br>Reason: %3<br><br>").arg(mod->name(), mod->fileinfo().fileName(), reason); |
| 71 | } |
| 72 | |
| 73 | ScrollMessageBox message_dialog(m_parent, tr("Metadata generation failed"), |
| 74 | tr("Could not generate metadata for the following mods:<br>" |
| 75 | "Do you wish to proceed without those mods?"), |
| 76 | text); |
| 77 | message_dialog.setModal(true); |
| 78 | if (message_dialog.exec() == QDialog::Rejected) { |
| 79 | m_aborted = true; |
| 80 | QMetaObject::invokeMethod(this, "reject", Qt::QueuedConnection); |
| 81 | return; |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | auto versions = mcVersions(m_instance); |
| 86 | auto loaders = mcLoaders(m_instance); |
| 87 | |
| 88 | SequentialTask check_task(m_parent, tr("Checking for updates")); |
| 89 | |
| 90 | if (!m_modrinth_to_update.empty()) { |
| 91 | m_modrinth_check_task = new ModrinthCheckUpdate(m_modrinth_to_update, versions, loaders, m_mod_model); |
| 92 | connect(m_modrinth_check_task, &CheckUpdateTask::checkFailed, this, |
| 93 | [this](Mod* mod, QString reason, QUrl recover_url) { m_failed_check_update.append({mod, reason, recover_url}); }); |
| 94 | check_task.addTask(m_modrinth_check_task); |
| 95 | } |
| 96 | |
| 97 | if (!m_flame_to_update.empty()) { |
| 98 | m_flame_check_task = new FlameCheckUpdate(m_flame_to_update, versions, loaders, m_mod_model); |
| 99 | connect(m_flame_check_task, &CheckUpdateTask::checkFailed, this, |
| 100 | [this](Mod* mod, QString reason, QUrl recover_url) { m_failed_check_update.append({mod, reason, recover_url}); }); |
| 101 | check_task.addTask(m_flame_check_task); |
| 102 | } |
| 103 | |
| 104 | connect(&check_task, &Task::failed, this, |
| 105 | [&](QString reason) { CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->exec(); }); |
| 106 | |
| 107 | connect(&check_task, &Task::succeeded, this, [&]() { |
| 108 | QStringList warnings = check_task.warnings(); |
| 109 | if (warnings.count()) { |
| 110 | CustomMessageBox::selectable(this, tr("Warnings"), warnings.join('\n'), QMessageBox::Warning)->exec(); |
| 111 | } |
| 112 | }); |
no test coverage detected