Part 1: Ensure we have a valid metadata
| 258 | |
| 259 | // Part 1: Ensure we have a valid metadata |
| 260 | auto ModUpdateDialog::ensureMetadata() -> bool |
| 261 | { |
| 262 | auto index_dir = indexDir(); |
| 263 | |
| 264 | SequentialTask seq(tr("Looking for metadata")); |
| 265 | |
| 266 | // A better use of data structures here could remove the need for this QHash |
| 267 | QHash<QString, bool> should_try_others; |
| 268 | QList<Mod*> modrinth_tmp; |
| 269 | QList<Mod*> flame_tmp; |
| 270 | |
| 271 | bool confirm_rest = false; |
| 272 | bool try_others_rest = false; |
| 273 | bool skip_rest = false; |
| 274 | ModPlatform::ResourceProvider provider_rest = ModPlatform::ResourceProvider::MODRINTH; |
| 275 | |
| 276 | auto addToTmp = [&](Mod* m, ModPlatform::ResourceProvider p) { |
| 277 | switch (p) { |
| 278 | case ModPlatform::ResourceProvider::MODRINTH: |
| 279 | modrinth_tmp.push_back(m); |
| 280 | break; |
| 281 | case ModPlatform::ResourceProvider::FLAME: |
| 282 | flame_tmp.push_back(m); |
| 283 | break; |
| 284 | } |
| 285 | }; |
| 286 | |
| 287 | for (auto candidate : m_candidates) { |
| 288 | if (candidate->status() != ModStatus::NoMetadata) { |
| 289 | onMetadataEnsured(candidate); |
| 290 | continue; |
| 291 | } |
| 292 | |
| 293 | if (skip_rest) |
| 294 | continue; |
| 295 | |
| 296 | if (candidate->type() == ResourceType::FOLDER) { |
| 297 | continue; |
| 298 | } |
| 299 | |
| 300 | if (confirm_rest) { |
| 301 | addToTmp(candidate, provider_rest); |
| 302 | should_try_others.insert(candidate->internal_id(), try_others_rest); |
| 303 | continue; |
| 304 | } |
| 305 | |
| 306 | ChooseProviderDialog chooser(this); |
| 307 | chooser.setDescription(tr("The mod '%1' does not have a metadata yet. We need to generate it in order to track relevant " |
| 308 | "information on how to update this mod. " |
| 309 | "To do this, please select a mod provider which we can use to check for updates for this mod.") |
| 310 | .arg(candidate->name())); |
| 311 | auto confirmed = chooser.exec() == QDialog::DialogCode::Accepted; |
| 312 | |
| 313 | auto response = chooser.getResponse(); |
| 314 | |
| 315 | if (response.skip_all) |
| 316 | skip_rest = true; |
| 317 | if (response.confirm_all) { |
nothing calls this directly
no test coverage detected